简体   繁体   English

转到 <select> HTML中的输入元素

[英]tab to <select> input element in html

I have a form , and within it several input and select elements. 我有一个form ,其中有几个inputselect元素。 My problem is that I can use tab to move between input elements, but not the select drop down menu. 我的问题是我可以使用Tab键在input元素之间移动,但不能使用select下拉菜单。 I tried tabindex="2" attribute, but it didn't affect anything. 我尝试了tabindex="2"属性,但没有任何影响。

Is there way to do this? 有办法吗?

Here is a sample of my code. 这是我的代码示例。 If it changes anything I'm in php, but I'm not able to get it to tab in html ether. 如果它改变了我在php中的任何内容,但我无法将其显示在html ether中。

<table>
    <tr>
        <td>
        <select>
            <option value="volvo">Volvo</option><option value="saab">Saab</option><option value="mercedes">Mercedes</option><option value="audi">Audi</option>
        </select></td><td>
        <input type="text" name="location" size=17 maxlength=22/>
        </td><td>
        <input type="text" name="date" size=12 maxlength=10/>
        </td>
    </tr>
</table>

I hope I posted this right I'm have a hard time with the code. 希望我对此发表正确的意见,以使我对代码感到困难。

On Firefox, for example, the select element on your real life sample page http://cafe.bg14.com/purchases.php can be tabbed to, it's just late in the tabbing order. 在Firefox,例如, select你的现实生活样本页面上元素http://cafe.bg14.com/purchases.php 可以对标签,它只是在跳位顺序晚。 The reason is that you are setting tabindex attribute for some form fields but not all. 原因是您要为某些表单字段(而非全部)设置tabindex属性。 Those without the attribute will come last. 那些没有属性的人将排在最后。

Either remove all tabindex attributes (if the natural tabbing order, by order in HTML markup, is OK), or use them for all fields and other items that should participate in tabbing. 删除所有tabindex属性(如果按HTML标记中的顺序按自然制表顺序是可以的),或者将它们用于所有字段和应参与制表的其他项目。

You should also fix the markup, using HTML W3C validator, after deciding which version of HTML you wish to use. 在确定要使用哪个版本的HTML之后,还应该使用HTML W3C验证程序来修复标记。 The page now declares XHTML 1.0 but uses unquoted attribute values and HTML5 features. 该页面现在声明了XHTML 1.0,但使用了未引用的属性值和HTML5功能。 This makes it more difficult to see that there are serious markup errors, like th elements not wrapped inside a tr element. 这使得它更难以看到有严重标记错误,就像th不包裹内的元素tr元素。 (Breaking the HTML table model may have an impact on both rendering and functionality.) (破坏HTML表模型可能会同时影响呈现和功能。)

Try below code i have tested it and its working too. 尝试下面的代码,我已经测试了它,它的工作也。
I answering it based on what you are asking to do in your question. 我根据您的问题要求回答。

<form action="#" method="post">
   <p><input type="text" name="first" tabindex="10" /></p>
   <p><input type="text" name="second" tabindex="20" /></p>
   <p>
      <select name="third" tabindex="30">
           <option value="foo">Foo</option>
           <option value="bar">Bar</option>
      </select>
   </p>
   <p>
      <select name="fourth" tabindex="40">
           <option value="foo">Foo</option>
           <option value="bar">Bar</option>
      </select>
   </p>
   <p><input type="text" name="fifth" tabindex="50" /></p>
   <input type="submit" value="Submit" tabindex="100" />
</form>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM