code_junkie

How to set selected index of dropdown to 0 when text of textbox is changed?

Nov 13th, 2011
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. function ResetDropDown(id) {
  2. document.getElementById(id).selectedIndex = 0;
  3. }
  4. function ResetTextBox(id) {
  5. document.getElementById(id).value = '';
  6. }
  7. <select id="MyDropDown" onchange="ResetTextBox('MyTextBox');">
  8. <option value="0">0</option>
  9. <option value="1">1</option>
  10. <option value="2">2</option>
  11. </select>
  12. <input id="MyTextBox" type="text" onkeypress="ResetDropDown('MyDropDown');"/>
Add Comment
Please, Sign In to add comment