Results 1 to 2 of 2

Thread: cancelBubble

  1. #1
    Join Date
    Dec 1969

    Default cancelBubble

    event is fired when button to &#039;submit&#039; form is clicked:<BR>&#060;button style="height:18pt;" type="submit" onclick="fnCheck()"&#062;<BR><BR>The purpose of this function is to stop the form&#039;s &#039;action&#039; event if the client does not make a valid selection.<BR><BR>function fnCheck() {<BR>var sel = document.frmSearch.selCat;<BR>if(sel.options[sel.selectedIndex].value == "0") {<BR><BR>//DEBUG CODE<BR>alert("selection.value==0");<BR>//END DEBUG CODE<BR><BR>event.cancelBubble=true;<BR>return false;}<BR>}<BR><BR>problem:<BR>the alert is displayed, but the page continues to execute the form&#039;s action, and loads the next page.

  2. #2
    Join Date
    Dec 1969

    Default You forgot to return value

    &#060;button style="height:18pt;" type="submit" onclick="[hl="yellow"]return [/hl]fnCheck()"&#062;<BR><BR>If you don&#039;t explicitly return a value from the onClick, then you usually get a TRUE, so the submit then proceeds.<BR><BR><BR>

Posting Permissions

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