programmatically select an option in "select" box in html

R

rvelosoo

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
 
B

Bart Van der Donck

rvelosoo said:
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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,830
Latest member
ZADIva7383

Latest Threads

Top