Click to See Complete Forum and Search --> : What does this do?


krismisz
02-03-2003, 07:51 PM
I have a quick question that may seem very simple to some of you, but keep in mind *I'm a beginner!*

What does this line do exactly?

<P><FORM ACTION="http://www.mydomain.com/cgi-bin/quiz.pl" method=post target="_blank">
<blockquote>

I'm trying to see if it would work for something that I want to do, but I don't know what it is and don't know how to use it. Please help!

Thanks!
krismisz

pyro
02-03-2003, 07:55 PM
That line calls quiz.pl, when the form is submitted. Will it work for what you want? Well, that depends on the content of quiz.pl and what you want to do with it.

krismisz
02-03-2003, 08:02 PM
Wow! You answered so fast, thanks!

I'm building a questionairre that will tell the visitor what "category" they fall into depending on which radio buttons on the form they select for the different questions. I've seen websites that do this and I want to know how it was done. Is there a website that I could try that has free scripts or anyone willing to help?

Thanks
krismisz

pyro
02-03-2003, 08:16 PM
Ok, the logic behind these questionaires is somthing like this...

The catergory they fall into depends on the number of times the hit radio buttons in each row. For instance if you have questions like:

O Yes O No | Do you know HTML
O Yes O No | Do you know JavaScript
O Yes O No | Do you know CSS
O Yes O No | Do you know PHP

If they answer yes for all, they fall into catergory one (web programming masters)

If they answer yes for two, they fall into catergory two (good programers)

If they answer yes for one or less, they fall into catergory three (need some work)

Hope that helps you out a bit...

krismisz
02-03-2003, 08:22 PM
Yes! That's exactly what I'm talking about! No one seems to get what I'm saying...anyway, how do you make the form go to a different page displaying which category they fall into and the reasoning behind once they hit the "Send" button. Do I use a script like the one before? But how to make it all work?

Thanks for all of your help so far!
krismisz

pyro
02-03-2003, 08:27 PM
The first thing for you to do would be to decide which language you would like to use to do this. It could be done in Perl, PHP, or even JavaScript (which is what I would use). Also, how many choices are you going to have for each question?

krismisz
02-03-2003, 08:42 PM
Let's go with Javascript...probably about 9 or 10 choices each time.

pyro
02-03-2003, 08:48 PM
Ok, next thing would be to see exactly what you want. Are you trying to allow users to rate themselves, or what. It depends on what you want for how it needs to be done. For instance, if you want them to rate themselves on different issues from on to ten, then, you could just add up all the ratings, and if the receive a certain score, they go to a certain page. Let me know what you are looking for.

krismisz
02-03-2003, 08:51 PM
I was thinking a variation of that...let's say that all answer "a" choices are worth 1 pt, answer "b" is 2 pts, etc...they're rating to see which celebrity would be their perfect match...a bit silly but it's fun.

krismisz
02-03-2003, 09:19 PM
pyro, are you still there?

pyro
02-03-2003, 09:22 PM
Yes, I'm working on it. Give me a bit...

pyro
02-03-2003, 10:32 PM
Ok, here's what I came up with. I know it's not the best way to do it, but I was in a hurry... I hope you can see what it's doing, and how to add more, but if you can't let me know.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Questionaire</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<script type="text/javascript">

function test()
{
total=0;
for (i=0; i<10; i++)
{
if (form1.question[i].checked)
{
total += Number(form1.question[i].value);
}
if (form1.question2[i].checked)
{
total += Number(form1.question2[i].value);
}
}
if (total <=9)
{
alert("You have less than 10");
}
else if (total >= 10 && total <=15)
{
alert("You between 10 and 15");
}
else
{
alert("You more than 15");
}
}

</script>

</head>

<body>
<form name="form1" method="post" action="">
<table width="100%" border="1">
<tr>
<td>&nbsp;</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td>10</td>
</tr>
<tr>
<td>Question One</td>
<td><input type="radio" name="question" value="1"></td>
<td><input type="radio" name="question" value="2"></td>
<td><input type="radio" name="question" value="3"></td>
<td><input type="radio" name="question" value="4"></td>
<td><input type="radio" name="question" value="5"></td>
<td><input type="radio" name="question" value="6"></td>
<td><input type="radio" name="question" value="7"></td>
<td><input type="radio" name="question" value="8"></td>
<td><input type="radio" name="question" value="9"></td>
<td><input type="radio" name="question" value="10"></td>
</tr>
<tr>
<td>Question Two</td>
<td><input type="radio" name="question2" value="1"></td>
<td><input type="radio" name="question2" value="2"></td>
<td><input type="radio" name="question2" value="3"></td>
<td><input type="radio" name="question2" value="4"></td>
<td><input type="radio" name="question2" value="5"></td>
<td><input type="radio" name="question2" value="6"></td>
<td><input type="radio" name="question2" value="7"></td>
<td><input type="radio" name="question2" value="8"></td>
<td><input type="radio" name="question2" value="9"></td>
<td><input type="radio" name="question2" value="10"></td>
</tr>
</table>
<p>&nbsp;</p>
<p>
<input type="button" name="Submit" value="Submit" onClick="test()">
</p>
</form>
</body>
</html>

krismisz
02-03-2003, 11:55 PM
I can't even begin to thank you enough for all of your help.

I see how the script works...however, I keep getting a Javascript error message when I test it out. The error is "object expected"...I think it's just because I haven't filled anything out.

Thank you so much for your time and your patience. If you want, I'd be so glad to post a link to your website from mine once it's up. Either way, I'm going to put your name in my "thanks/credits" section.

Thanks so much!
krismisz

pyro
02-04-2003, 12:03 AM
If you need more help, let me know. I'd be glad to offer any assistance possible.

Cheers.

krismisz
02-04-2003, 01:20 AM
I hate to be a bother, but I have another quick question for you. Is there a simple way to do a different script for "mostly a's", "mostly b's", etc?

If you're tired of helping, I completely understand, but I would be so grateful for any help you can give me!

Thanks so much!
krismisz

pyro
02-04-2003, 08:33 AM
Here are the modifications...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Questionaire</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<script type="text/javascript">

function questionaire()
{
a=0;
b=0;
for (i=0; i<2; i++)
{
//--------Add and modify for each new question--------
if (form1.question[i].checked)
{
if (document.form1.question[i].value == "a")
{
a++;
}
else
{
b++;
}
}
//--------Add and modify for each new question--------
if (form1.question2[i].checked)
{
if (document.form1.question2[i].value == "a")
{
a++;
}
else
{
b++;
}
}
//--------Add and modify for each new question--------
}
if (a > b)
{
alert ("You chose more A's");
}
else if (a == b)
{
alert ("You chose the same number of A's and B's");
}
else
{
alert ("You chose more B's");
}
}

</script>

</head>

<body>
<form name="form1" method="post" action="">
<table width="100%" border="1">
<tr>
<td>&nbsp;</td>
<td>A</td>
<td>B</td>
</tr>
<tr>
<td>Question One</td>
<td><input type="radio" name="question" value="a"></td>
<td><input type="radio" name="question" value="b"></td>
</tr>
<tr>
<td>Question Two</td>
<td><input type="radio" name="question2" value="a"></td>
<td><input type="radio" name="question2" value="b"></td>
</tr>
</table>
<p>&nbsp;</p>
<p>
<input type="button" name="Submit" value="Submit" onClick="questionaire()">
</p>
</form>
</body>
</html>