Hi everybody,
I am just learning to use the Confirm Box feature in Javascript. I have tried to add it onto HTML form's submit buttons and checkboxes without problem. But when I add it to a HTML drop down list the behavior is a bit different and unexpected. My code looks like this:
<select name='mychoice' onclick='return confirm("Are you sure?");'>
<option value='1' selected='selected'>Apple</option>
<option value='2'>Orange</option>
<option value='3'>Lemon</option>
</select>
When I select one choice (whether it is Apple or Orange or Lemon), the Confirm Box pops up as expected. The problem is, when I press Cancel, the original choice will not appear, unlike checkboxes. In other words, pressing OK and Cancel will lead to the same result. Is my code wrong, or is there any simple way to make the original choice re-appear when Cancel is pressed?
Thanks,
pengi.