programmatically select an option in "select" box in html

Discussion in 'Javascript' started by rvelosoo, Aug 13, 2008.

  1. rvelosoo

    rvelosoo Guest

    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
    rvelosoo, Aug 13, 2008
    #1
    1. Advertising

  2. 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
    Bart Van der Donck, Aug 13, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Oskar Wild
    Replies:
    2
    Views:
    166
    Oskar Wild
    Aug 28, 2003
  2. palmiere
    Replies:
    1
    Views:
    400
    Erwin Moller
    Feb 9, 2004
  3. mr_burns

    JS to select an option in a combo box

    mr_burns, Apr 2, 2004, in forum: Javascript
    Replies:
    4
    Views:
    81
    Frostillicus
    Apr 4, 2004
  4. J1C

    Programmatically Select Option

    J1C, Jun 16, 2005, in forum: Javascript
    Replies:
    4
    Views:
    126
  5. Generale Cluster
    Replies:
    1
    Views:
    953
    Frobernik
    May 31, 2010
Loading...

Share This Page