Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > programmatically select an option in "select" box in html

Reply
Thread Tools

programmatically select an option in "select" box in html

 
 
rvelosoo
Guest
Posts: n/a
 
      08-13-2008
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
 
Reply With Quote
 
 
 
 
Bart Van der Donck
Guest
Posts: n/a
 
      08-13-2008
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to programmatically select an option in jquery ui autocomplete Generale Cluster Javascript 1 05-31-2010 09:44 PM
modify the default option in a select changing another select WebRaster Javascript 1 10-26-2005 10:36 AM
Programmatically Select Option J1C Javascript 4 06-22-2005 06:40 PM
Selection from One SELECT changes selected option of another SELECT? J. Hall HTML 2 04-21-2004 05:36 PM
select of select box will select multiple in another box palmiere Javascript 1 02-09-2004 01:11 PM



Advertisments