+ Reply to Thread
Results 1 to 2 of 2

Thread: change <select> value

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    15

    change <select> value

    I have a <select> whit a list of options and a default value. After the user selects an option and clicks on a button, I want the select to go back to its default value.
    Code:
    <select id="select">
     <option value="defaultValue">Default</option>
     <option value="Option1">Option1</option>
     <option value="Option2">Option2</option>    
    </select>
    <input type="button" value="CHANGE" onclick="selectFunction()" />
    I tried
    Code:
    document.getElementById("select").value = "defaultValue"
    but is not working.

  2. #2
    Junior Member
    Join Date
    Jan 2012
    Posts
    13
    You set the selectedIndex:
    Code:
    document.getElementById("select").selectedIndex = 0;
    That should select the first value which is the default one

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts