Javascript help on ASP page

Results 1 to 2 of 2

Thread: Javascript help on ASP page

  1. #1
    Join Date
    Dec 1969

    Default Javascript help on ASP page

    I have a main page on which there are these checkboxes and i am trying to write a javascript checking to see if one ofthese checkboxes are checked. If it is no then there is a message that comes up... The problem with this is, after clicking on the OK button of the Alert message it automatically goes to the next page and does not stay on this main page till i check one of the boxes. Why is this happening.?? I have a &#060;Form&#062; tag posting these checked checkboxes to another page so that data can be retrieved from the SQL Server DB and displayed on the next page.<BR><BR><BR>&#060;SCRIPT LANGUAGE="JAVASCRIPT"&#062;<BR>&#060;!--<BR> function checkCheckboxes()<BR> {<BR> if( document.forms[0].CHECKBOX1.checked==false &&<BR> document.forms[0].CHECKBOX2.checked==false &&<BR> document.forms[0].CHECKBOX3.checked==false &&<BR> document.forms[0].CHECKBOX4.checked==false &&<BR> document.forms[0].CHECKBOX5.checked==false &&<BR> document.forms[0].CHECKBOX6.checked==false &&<BR> document.forms[0].CHECKBOX7.checked==false &&<BR> document.forms[0].CHECKBOX8.checked==false)<BR> <BR> {<BR> alert("Please check one of the categories you want to view");<BR> document.forms[0].CHECKBOX1.focus();<BR> return false;<BR> }<BR> else<BR> {<BR> return true;<BR> }<BR> <BR> <BR> }<BR>//--&#062; <BR>&#060;/SCRIPT&#062;

  2. #2
    Join Date
    Dec 1969

    Default RE: Javascript help on ASP page

    You don&#039t show your &#060;FORM...&#062; line, but I would bet that you are simply doing something like this:<BR><BR>&#060;FORM Name="Whatever" Action="xxx.asp" Method="POST" onSubmit="checkCheckboxes();"&#062;<BR><BR>OOPS! Mistake!<BR><BR>Minor change needed:<BR><BR>&#060;FORM Name="Whatever" Action="xxx.asp" Method="POST" onSubmit="return checkCheckboxes();"&#062;<BR><BR>See it? I added the "return" in the onSubmit.<BR><BR>Your *function* returning the right value, but unless you tell "onSubmit" to pass on that value, it doesn&#039t. And it simply always then passes back true. <BR><BR>Tell me if I guessed right.<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