Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to make a function break 1

Status
Not open for further replies.

sbayter

IS-IT--Management
Joined
Nov 14, 2002
Messages
95
Location
CO
Hi,
I have a survey which is composed of around 10 question. For each question you can answer from 1 to 10 using radio button.
I have a script validator with a if statements for each question so if the user does not check any radio in some question it will tell the user to try again.
The problem is that when user does not check any of the questions it pops up the 10 alert of each if statement.
At the edn of each if statment I have "event.returnValue=false;".
Is there any way to make the function break if one of the if statements is executed?
I tried inserting a "break" but if did not work.
Thanks in advance for ur help,


sbayter
 
return false;

_________________________________________________________
for the best results to your questions: FAQ333-2924
01001111 01101110 01110000 01101110 01110100
onpnt2.gif
[/sub]
 
I tried with return false. The problem with this is that the page is a php page sowhen it returns false it goes to another page and displays the default php error.
However, when i use "event.returnValue=false;", it doesn't.
Any other option?
Thanks,

sbayter
 
Design your validator to pop an alert if and only if any question (or combination of questions) is unanswered, but only when hitting whatever passes for a Submit button, to the tune of "All questions must be answered before continuing, please."

Because you only have 10 questions, the more highly-evolved users can quickly figure out where they didn't finish.

Does your interface allow people to answer the questions in any order?

curious,


[monkey] Edward [monkey]

Like Lovecraft? Know Photoshop? Got time for the Unspeakable?
 
any other suggestions?

sbayter
 
shooting in the wind................

can you post the function?

_________________________________________________________
for the best results to your questions: FAQ333-2924
01001111 01101110 01110000 01101110 01110100
onpnt2.gif
[/sub]
 
<script language=&quot;Javascript&quot;>
function validate() {
if (!(form2.SUB1[0].checked || form2.SUB1[1].checked || form2.SUB1[2].checked || form2.SUB1[3].checked || form2.SUB1[4].checked || form2.SUB1[5].checked || form2.SUB1[6].checked || form2.SUB1[7].checked || form2.SUB1[8].checked || form2.SUB1[9].checked || form2.SUB1[10].checked || form2.SUB1[11].checked)) {
alert('Incomplete response. Please go back and try again');
return (false);
}
if (!(form2.SUB2[0].checked || form2.SUB2[1].checked || form2.SUB2[2].checked || form2.SUB2[3].checked || form2.SUB2[4].checked || form2.SUB2[5].checked || form2.SUB2[6].checked || form2.SUB2[7].checked || form2.SUB2[8].checked || form2.SUB2[9].checked || form2.SUB2[10].checked || form2.SUB2[11].checked)) {
alert('Incomplete response. Please try again.');
return (false);
}
if (!(form2.SUB3[0].checked || form2.SUB3[1].checked || form2.SUB3[2].checked || form2.SUB3[3].checked || form2.SUB3[4].checked || form2.SUB3[5].checked || form2.SUB3[6].checked || form2.SUB3[7].checked || form2.SUB3[8].checked || form2.SUB3[9].checked || form2.SUB3[10].checked || form2.SUB3[11].checked)) {
alert('Incomplete response. Please try again.');
return (false);
}
if (!(form2.SUB4[0].checked || form2.SUB4[1].checked || form2.SUB4[2].checked || form2.SUB4[3].checked || form2.SUB4[4].checked || form2.SUB4[5].checked || form2.SUB4[6].checked || form2.SUB4[7].checked || form2.SUB4[8].checked || form2.SUB4[9].checked || form2.SUB4[10].checked || form2.SUB4[11].checked)) {
alert('Incomplete response. Please try again.');
return (false);
}
if (!(form2.SUB5[0].checked || form2.SUB5[1].checked || form2.SUB5[2].checked || form2.SUB5[3].checked || form2.SUB5[4].checked || form2.SUB5[5].checked || form2.SUB5[6].checked || form2.SUB5[7].checked || form2.SUB5[8].checked || form2.SUB5[9].checked || form2.SUB5[10].checked || form2.SUB5[11].checked)) {
alert('Incomplete response. Please try again.');
return (false);
}
if (!(form2.SUB6[0].checked || form2.SUB6[1].checked || form2.SUB6[2].checked || form2.SUB6[3].checked || form2.SUB6[4].checked || form2.SUB6[5].checked || form2.SUB6[6].checked || form2.SUB6[7].checked || form2.SUB6[8].checked || form2.SUB6[9].checked || form2.SUB6[10].checked || form2.SUB6[11].checked)) {
alert('Incomplete response. Please try again.');
return (false);
}
if (!(form2.SUB7[0].checked || form2.SUB7[1].checked || form2.SUB7[2].checked || form2.SUB7[3].checked || form2.SUB7[4].checked || form2.SUB7[5].checked || form2.SUB7[6].checked || form2.SUB7[7].checked || form2.SUB7[8].checked || form2.SUB7[9].checked || form2.SUB7[10].checked || form2.SUB7[11].checked)) {
alert('Incomplete response. Please try again.');
return (false);
}
if (!(form2.SUB8[0].checked || form2.SUB8[1].checked || form2.SUB8[2].checked || form2.SUB8[3].checked || form2.SUB8[4].checked || form2.SUB8[5].checked || form2.SUB8[6].checked || form2.SUB8[7].checked || form2.SUB8[8].checked || form2.SUB8[9].checked || form2.SUB8[10].checked || form2.SUB8[11].checked)) {
alert('Incomplete response. Please try again.');
return (false);
}
if (!(form2.SUB9[0].checked || form2.SUB9[1].checked || form2.SUB9[2].checked || form2.SUB9[3].checked || form2.SUB9[4].checked || form2.SUB9[5].checked || form2.SUB9[6].checked || form2.SUB9[7].checked || form2.SUB9[8].checked || form2.SUB9[9].checked || form2.SUB9[10].checked || form2.SUB9[11].checked)) {
alert('Incomplete response. Please try again.');
return (false);
}
if (!(form2.SUB10[0].checked || form2.SUB10[1].checked || form2.SUB10[2].checked || form2.SUB10[3].checked || form2.SUB10[4].checked || form2.SUB10[5].checked || form2.SUB10[6].checked || form2.SUB10[7].checked || form2.SUB10[8].checked || form2.SUB10[9].checked || form2.SUB10[10].checked || form2.SUB10[11].checked)) {
alert('Incomplete response. Please try again.');
return (false);
}
if (!(form2.SUB11[0].checked || form2.SUB11[1].checked || form2.SUB11[2].checked || form2.SUB11[3].checked || form2.SUB11[4].checked || form2.SUB11[5].checked || form2.SUB11[6].checked || form2.SUB11[7].checked || form2.SUB11[8].checked || form2.SUB11[9].checked || form2.SUB11[10].checked || form2.SUB11[11].checked)) {
alert('Incomplete response. Please try again.');
return (false);
}
}
</script>

sbayter
 
take out the ( ) around false
return false;

then on the call you need to du
return validate()

there is no reasoning I can think this would not work unless this is a browser issue

_________________________________________________________
for the best results to your questions: FAQ333-2924
01001111 01101110 01110000 01101110 01110100
onpnt2.gif
[/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top