Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Javascript (http://www.velocityreviews.com/forums/f68-javascript.html)
-   -   programmatically select an option in "select" box in html (http://www.velocityreviews.com/forums/t936792-programmatically-select-an-option-in-select-box-in-html.html)

rvelosoo 08-13-2008 09:47 AM

programmatically select an option in "select" box in html
 
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

Bart Van der Donck 08-13-2008 10:53 AM

Re: programmatically select an option in "select" box in html
 
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


All times are GMT. The time now is 08:10 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.