| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
|
|
#1 (permalink) |
|
Registered User
|
ok I'm tearing my head out as I need a form with 5 questions with answers yes or no as radio buttons then based on their answers it outputs a peice of text - I haven't a clue on what to write - I've got a kind of scripty thing that of course does nothing but shows what I need... the radio buttons are named question_x_yes or question_x_no - am I on the right lines as I couldn't find any relevant scripts on the net - HELP?! <SCRIPT LANGUAGE="JavaScript"><!-- function cycle() { if question_1_yes = "true" & question_2_no="false" & question_3_no="false" & question_4_no="4" & question_5_yes="true" or "false" then document.write = "option 1" else if question_1_yes = "true" & qestion_2_yes="true" & question_3_no="false" & question_4_yes="yes" & qeuestion_5_yes="true" then document.write = "option 2" else if question_1_yes = "true" & qestion_2_yes="true" & question_3_yes="true" & question_4_yes="yes" & qeuestion_5_yes="true" or "false" then document.write = "option 3" else if question_1_yes = "true" & qestion_2_yes="true" & question_3_no="false" & question_4_yes="yes" & qeuestion_5_no="false" then document.write = "Option 4" else document.write "unfortunately we're unable to do anything." //--></SCRIPT> |
|
|
|
|
|
#2 (permalink) |
|
Senior Member
Join Date: Feb 2003
Location: Canterbury
Posts: 115
|
I don't think so - there are to many 'elses'. From the programming I've done else simply provides you with ONE alternative to the original IF. In other words you acn't have IF a ELSE b ELSE c - the ELSE c bit would be useless as ELSE b would cover every situation other than the original IF a. I hope that makes sense. Um what would work though.... Can you set it up in a loop? I mean have the 5 different options (6 if you include the "unfortunately we're unable to do anything.") and use a call function if option 1 isn't true then call option 2, if that aint true then call option 3 etc. Might work, might not! Living in the Slow Lane
|
|
|
|
#5 (permalink) | |
|
I Ain't Losing Any Sleep™
Join Date: Apr 2003
Posts: 5,236
|
I don't know about the actual script working or even Javascript but as far as formatting goes... I think it should be if ( condition ) statement or block else statement or block So... Quote:
That's fuckin' ingenious, if I understand it correctly. It's a Swiss fuckin' watch.
|
|
|
|
|
#6 (permalink) |
|
Registered User
|
the documnet.write - urmmmm can I specify where abouts on the screen the answer is outputted to - god Iain't a clue how it's going to work. I was also told I should have double == and && EEEEK then comes the fun of calling it from the form submit.... why me! if (question_1_yes == "true" && question_2_no="false" && question_3_no="false" && question_4_no="4") document.write = "option 1"; |
|
![]() |