By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,695 Members | 1,597 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,695 IT Pros & Developers. It's quick & easy.

programmatically select an option in "select" box in html

P: n/a
Hi,

I'm having trouble selecting an option in html, i.e. i change the
code, but the change is not reflected in the browser.
Example, i have
<select>
<option>A
<option selected>B
</selected>

if I click A and refresh the page, the select box will still be in A,
even though according to the code should be pointed to B. I'm using
firefox. Any suggestion? thanks
Aug 13 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
rvelosoo wrote:
I'm having trouble selecting an option in html, i.e. i change the
code, but the change is not reflected in the browser.
Example, i have
<select>
<option>A
<option selected>B
</selected>
if I click A and refresh the page, the select box will still be in A,
even though according to the code should be pointed to B. I'm using
firefox. Any suggestion? thanks
<body onLoad="document.forms[0].s.selectedIndex = 1;">
<form method="get" action="#">
<select name="s" size="1">
<option value="A">A</option>
<option value="B" selected>B</option>
</selected>
</form>
</body>

--
Bart
Aug 13 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.