Old 03-07-2003, 11:23   #1 (permalink)
the_purple_ostrich
Registered User
 
Join Date: Mar 2003
Posts: 64
Send a message via Yahoo to the_purple_ostrich
poxy javascript

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>
  Reply With Quote
Old 03-07-2003, 11:44   #2 (permalink)
dcd
Senior Member
 
dcd's Avatar
 
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
  Reply With Quote
Old 04-07-2003, 04:00   #3 (permalink)
the_purple_ostrich
Registered User
 
Join Date: Mar 2003
Posts: 64
Send a message via Yahoo to the_purple_ostrich
pass - I haven't done prgramming in over 5 years and am totally stumped!
  Reply With Quote
Old 04-07-2003, 04:56   #4 (permalink)
dcd
Senior Member
 
dcd's Avatar
 
Join Date: Feb 2003
Location: Canterbury
Posts: 115
There must be someone who knows!!!
__________________
Living in the Slow Lane
  Reply With Quote
Old 04-07-2003, 05:14   #5 (permalink)
smallbeer
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:
<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")
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")
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")
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")
document.write = "Option 4";

else
document.write "unfortunately we're unable to do anything."

//--></SCRIPT>
__________________
That's fuckin' ingenious, if I understand it correctly. It's a Swiss fuckin' watch.
  Reply With Quote
Old 07-07-2003, 06:35   #6 (permalink)
the_purple_ostrich
Registered User
 
Join Date: Mar 2003
Posts: 64
Send a message via Yahoo to the_purple_ostrich
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";
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8