开发者

Selected option in view when SIZE is greater than 1

How do you get the selected option to be in view on page load?

<select name="whatever" size="5">  
    <option value="1">1<开发者_JAVA百科/option>  
    <option value="2">2</option>  
    <option value="3">3</option>  
    <option value="4">4</option>  
    <option value="5">5</option>  
    <option value="6">6</option>  
    <option value="7" selected>7</option>  
    <option value="8">8</option>  
    <option value="9">9</option>  
    <option value="10">10</option>  
</select>


If I understand you correctly, you want the item shown in the dropdown list to be the selected item when the page loads. By default behavior the selected view does in fact show "in view" on page load. What are you seeing that you do not expect?

note: your html should be

<option value="7" selected="selected">7</option>

to be a valid html tag.


All browsers I've tested (Firefox, Chrome, Opera and IE7) scroll the contents to display the selected option.

Edit: Windows XP

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜