Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
javascript form , yes and no questions!
Old 06-07-2005, 10:06 PM javascript form , yes and no questions!
Junior Talker

Posts: 2
Trades: 0
Need to find out if there is a way to do the following form I am working on,

It is a form with 10 questions, yes and no questions.

if all 10 questions are answered no, then go to the no.htm page
, but if all 10 questions are answered yes then go to the the yes.thm page.

Im guessing it will be in the form validation , but dont know where to start.

If ayone has any idea would be cool to fin dout., cheers
rasta_rocket is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-08-2005, 01:46 AM
Phaedrus's Avatar
Ultra Talker

Posts: 271
Location: CA
Trades: 0
This has 5 questions, but it will work for 10 just the same.
HTML Code:
<html>
<head>
<script language="javascript">
	function checkAnswers()
	{
		var answer = "none";
		var uniform = true;
		
		for (i=0;i<document.forms[0].elements.length;i++)
		{
			if (document.forms[0].elements[i].checked)
			{
				if (answer == "none")
				{
					answer = document.forms[0].elements[i].value;
				}
				else
				{
					if (document.forms[0].elements[i].value != answer)
					{
						uniform = false;		
					}
				}
			}
		}
		
		if ( (uniform == true) && (answer == "yes") ) 
		{ 
			window.location = "yes.htm";
		}
		else if ( (uniform == true) && (answer == "no") )
		{
			window.location = "no.htm";	
		}
		else 
		{
			alert ("Answers are not uniform");	
		}
	}
</script>
</head>
<body>
<form>

<p>To be or not to be?</p>
<p>
	<input type="radio" name="1" value="yes" /> Yes <br />
	<input type="radio" name="1" value="no" /> No
</p>

<p>To be or not to be?</p>
<p>
	<input type="radio" name="2" value="yes" /> Yes <br />
	<input type="radio" name="2" value="no" /> No
</p>

<p>To be or not to be?</p>
<p>
	<input type="radio" name="3" value="yes" /> Yes <br />
	<input type="radio" name="3" value="no" /> No
</p>

<p>To be or not to be?</p>
<p>
	<input type="radio" name="4" value="yes" /> Yes <br />
	<input type="radio" name="4" value="no" /> No
</p>

<p>To be or not to be?</p>
<p>
	<input type="radio" name="5" value="yes" /> Yes <br />
	<input type="radio" name="5" value="no" /> No
</p>


<input type="submit" onclick="checkAnswers();" />

</form>
</body>
</html>
__________________

Please login or register to view this content. Registration is FREE
Phaedrus is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to javascript form , yes and no questions!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.27054 seconds with 12 queries