select-onchange-after-js.html 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. "http://www.w3.org/TR/html4/loose.dtd">
  3. <html>
  4. <body>
  5. <p>Test for <a href="http://bugs.webkit.org/show_bug.cgi?id=11402">bug 11402</a> and
  6. <a href="http://bugs.webkit.org/show_bug.cgi?id=12701">bug 12701</a>:
  7. An onChange event should fire when the first item is not the default, and
  8. after changing the value via JavaScript.</p>
  9. <p>After following the steps below, both selects should display "SUCCESS".</p>
  10. <form action="" method="post" name="areaform" id="areaform">
  11. <select name="selectitem" onChange="onChange1(this)">
  12. <option value="1">Please change this to another value</option>
  13. <option value="2">(to this one)</option>
  14. </select>
  15. </form>
  16. <form action="" method="post" name="areaform2" id="areaform2">
  17. <select name="selectitem2" onChange="onChange2(this)">
  18. <option value="1">(to this one)</option>
  19. <option value="2" selected>Please change this to another value</option>
  20. </select>
  21. </form>
  22. <script>
  23. function onChange1(sel) {
  24. if (sel.secondTry) {
  25. sel.options[1].text='SUCCESS';
  26. } else {
  27. sel.options[0].text='Please change this to another value once again';
  28. sel.value = '1';
  29. sel.secondTry = 1;
  30. }
  31. }
  32. function onChange2(sel) {
  33. if (sel.secondTry) {
  34. sel.options[0].text='SUCCESS';
  35. } else {
  36. sel.options[1].text='Please change this to another value once again';
  37. document.forms.areaform2.selectitem2.options[1].selected = true;
  38. sel.secondTry = 1;
  39. }
  40. }
  41. </script>
  42. </body>
  43. </html>