Closed Thread Icon

Topic awaiting preservation: Javascript Survey (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=8162" title="Pages that link to Topic awaiting preservation: Javascript Survey (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Javascript Survey <span class="small">(Page 1 of 1)</span>\

 
counterfeitbacon
Paranoid (IV) Inmate

From: Vancouver, WA
Insane since: Apr 2002

posted posted 05-09-2002 04:30

I half-wrote some code for a javascript survey that I have to send out for my 8th grade term paper and I can't seem to get it to work. Whenever I try and test send it Outlook gives me a weird error sayiing that it can't send the results to gangsuvey@hotmail.com+ADRESS, (gangsurvey@hotmail.com was the adress I set up to collect info on) so If any of you JS gurus out their see some obvious error with the code I would appreciate it if you could tell me. Thanks.

<html>
<head>
<title>
Gangs Survey
</title>

<script language="JavaScript">
<!-- Hide from old browsers

function survey() {
var i = 0
var index1=document.form1.answer1.selectedIndex
var index2=document.form1.answer2.selectedIndex
var index3=document.form1.answer3.selectedIndex
var index4=document.form1.answer4.selectedIndex

var result1=document.form1.answer1.options[index1].value
var result2=document.form1.answer2.options[index2].value
var result3=document.form1.answer3.options[index3].value
var result4=document.form1.answer4.options[index4].value
var comments=document.form1.comments.value

if (result1!=0 && result2!=0 && result3!=0){
document.mail.question1.value = result1
document.mail.question2.value = result2
document.mail.question3.value = result3
document.mail.question4.value = result4
document.mail.comment.value = comments
return true;}
else {
alert("Please fill out all questions. Thank you."); return false;}

}
// -->
</script>

</head>

<h1>Gangs Survey</h1>
<h5>Hello. My name is Daniel Portin, a student at Shahala Middle School.<br>For my 8th grade term paper I decided to research gangs in<br>the Pacific Northwest. It would be very helpfull to me<br>(to fullfill one of the requirments) if you could take the time to fill out the survey.<p><p><p><p><p><p></h5>

<body>

<FORM NAME="form1">
<STRONG>What area of work are you involved in?<br></STRONG>
<SELECT NAME="answer1" SIZE=1>
<OPTION SELECTED VALUE="0">-- Choose an answer --
<OPTION VALUE="ANSWER #1">Law Enforcement
<OPTION VALUE="ANSWER #2">Medical
<OPTION VALUE="ANSWER #3">Public/Civil Services
<OPTION VALUE="ANSWER #4">Food Services
<OPTION VALUE="ANSWER #5">Grocer/Teller
<OPTION VALUE="ANSWER #6">Other
<OPTION VALUE="ANSWER #7">Unemployed/Under 16
</SELECT><BR><BR>

<STRONG>How old are you?<br></STRONG>
<SELECT NAME="answer2" SIZE=1>
<OPTION SELECTED VALUE="0">-- Choose an answer --
<OPTION VALUE="ANSWER #1">13 to 17
<OPTION VALUE="ANSWER #2">18 to 29
<OPTION VALUE="ANSWER #3">30 to 49
<OPTION VALUE="ANSWER #4">Over 50
</SELECT><BR><BR>

<STRONG>Please rate the gang problem in your area<br>on a scale of 1 to 10, with 1 being the<br>lowest and 10 being the highest.<br></STRONG>
<SELECT NAME="answer3" SIZE=1>
<OPTION SELECTED VALUE="0">-- Choose an answer --
<OPTION VALUE="ANSWER #1">1
<OPTION VALUE="ANSWER #2">2
<OPTION VALUE="ANSWER #3">3
<OPTION VALUE="ANSWER #4">4
<OPTION VALUE="ANSWER #5">5
<OPTION VALUE="ANSWER #6">6
<OPTION VALUE="ANSWER #7">7
<OPTION VALUE="ANSWER #8">8
<OPTION VALUE="ANSWER #9">9
<OPTION VALUE="ANSWER #10">10
</SELECT><BR><BR>

<STRONG>What type of criminal activity would you<br>most attribute to gangs in your area?<br></STRONG>
<SELECT NAME="answer4" SIZE=1>
<OPTION SELECTED VALUE="0">-- Choose an answer --
<OPTION VALUE="ANSWER #1">Murder/Homocide
<OPTION VALUE="ANSWER #2">Jumpings/Muggings
<OPTION VALUE="ANSWER #3">Graffiti
<OPTION VALUE="ANSWER #4">Robbery/Armed Robbery
<OPTION VALUE="ANSWER #5">Drug Possession/Selling
<OPTION VALUE="ANSWER #6">Other
</SELECT><BR><BR>

<STRONG>Please describe the gang problem in your area?<br></STRONG><BR>
<TEXTAREA NAME="comments" ROWS=5 COLS=50></TEXTAREA>
</FORM>

<FORM NAME="mail" method="POST" action="mailto:gangsurvey@hotmail.com
?subject=Survey Results" onSubmit="return survey()"
enctype="multipart/form-data">
<input type=hidden name="question1">
<input type=hidden name="question2">
<input type=hidden name="question3">
<input type-hidden name="question4">
<input type=hidden name="comment">
<INPUT TYPE="SUBMIT" VALUE="Submit Survey!">
</FORM>

</body>
</html>

stinx
Bipolar (III) Inmate

From: London, UK
Insane since: Apr 2002

posted posted 05-09-2002 16:49

Hehe - doesn't seem to be anything wrong with your code (apart from one minor typo in <input type-hidden name="question4"> where the '-' should be a '=')

Must be something to do with the setup of your mail client

stinx


Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 05-09-2002 18:21

A working version would really help here to figure out what's wrong.

dk01
Bipolar (III) Inmate

From: dk's house of love
Insane since: Oct 2001

posted posted 05-09-2002 18:28

How come you are using 'return true' in the survey function and also why did you do 'return survey()' in the onsubmit attribute?
Stinx is correct though, you should change the - to an = sign.
-dk

- can't decide? have another drink.

counterfeitbacon
Paranoid (IV) Inmate

From: Vancouver, WA
Insane since: Apr 2002

posted posted 05-10-2002 00:00

I changed the - to a =, but (I kinda took a crash course in JavaScipt when I wrote this) from what I read, then the return true should make it only submit if all the questions were filled out, and if they weren't then it would bring up an error message. The mail problem was it not submitting any data when it would send the return result e-mail through a web-based e-mail such as hotmail or juno.

counterfeitbacon
Paranoid (IV) Inmate

From: Vancouver, WA
Insane since: Apr 2002

posted posted 05-10-2002 01:54

changed the enctype to basic text, seemed to help a lot

« BackwardsOnwards »

Show Forum Drop Down Menu