/    Sign up×
Community /Pin to ProfileBookmark

Having a little trouble

I wrote a simple survey that uses php to submit the info to a MySQL database. The survey itself works and the data appears in the database, however, there is a little Javascript that is supposed to make sure all the questions have been answered, which is not working.
I copied the code from another survey I used and the code works fine on that survey. If a question is left unanswered, a window (alert) pops up stating that a question was left blank.

This particular survey, however, just submits the empty values to the database when the user clicks on “Submit”. The Javascript section to check and make sure all of the questions were answered does not seem to be working.

Here is my code:
<html>
<head>
<title>HCA Securities-Continuing Education Program Course Feedback and Evaluation Form</title>
<script language=”Javascript”>

function validate_form(){

if (surveyForm.name.value==””){
alert (“Please enter your name.”)
surveyForm.name.focus()
return false
}

if (surveyForm.date.value==””){
alert (“Please enter today’s date.”)
surveyForm.date.focus()
return false
}

if (surveyForm.course.value==””){
alert (“Please enter the course.”)
surveyForm.course.focus()
return false
}

pace=-1
for (i=0; i<surveyForm.pace.length; i++){
if (surveyForm.pace[i].checked){
pace=i
}
}
if (pace==-1){
alert(“Please select an answer for Question #1.”)
return false
}

time=-1
for (i=0; i<surveyForm.time.length; i++){
if (surveyForm.time[i].checked){
time=i
}
}
if (time==-1){
alert (“Please select an answer for
question #2.”)
return false
}

easy=-1
for (i=0; i<surveyForm.easy.length; i++){
if (surveyForm.time[i].checked){
easy=i
}
}
if (easy==-1){
alert (“Please select an answer for question
#3.”)
return false
}

clarity=-1
for (i=0; i<surveyForm.clarity.length; i++){
if (surveyForm.clarity[i].checked){
clarity=i
}
}
if (clarity==-1){
alert (“Please select an answer for question
#4.”)
return false
}

level=-1
for (i=0; i<surveyForm.level.length; i++){
if (surveyForm.level[i].checked){
level=i
}
}
if (level==-1){
alert (“Please select an answer for question
#5.”)
return false
}

learn=-1
for (i=0; i<surveyForm.learn.length; i++){
if (surveyForm.learn[i].checked){
learn=i
}
}
if (learn==-1){
alert (“Please select an answer for question
#6.”)
return false
}

impression=-1
for (i=0; i<surveyForm.impression.length; i++){
if (surveyForm.impression[i].checked){
impression=i
}
}
if (impression==-1){
alert (“Please select an answer for question
#7.”)
return false
}

useful=-1
for (i=0; i<surveyForm.useful.length; i++){
if (surveyForm.useful[i].checked){
useful=i
}
}
if (useful==-1){
alert (“Please select an answer for question
#7.)
return false
}

expectations=-1
for (i=0; i<surveyForm.expectations.length; i++){
if (surveyForm.expectations[1].checked){
expectations=i
}
}
if (expectations==-1){
alert (“Please select an answer for question
#8.”)
return false
}

recommend=-1
for (i=0; i<surveyForm.recommend.length; i++){
if (surveyForm.recommend[1].checked){
recommend=i
}
}
if (recommend==-1){
alert (“Please select an answer for question
#10.”)
return false
}

moretraining=-1
for (i=0; i<surveyForm.moretraining.length; i++){
if (surveyForm.moretraining[1].checked){
moretraining=i
}
}
if (moretraining==-1){
alert (“Please select an answer for question
#11.”)
return false
}
}
</script>
</head>
<body>
<form OnSubmit=”return validate_form(this)” NAME=”surveyForm” ACTION=”hcacecf-submit.php”>
<font face=”Garamond”>
<center>
<img src=”http://10.104.7.149/legal/hca-cecf/images/hca_logo.jpeg“>
<h3>HCA Securities, Inc.<br>
Continuing Education Program<br>
Course Feedback and Evaluation Form<br>
<hr align=center size=2 width=”100%”>
</center>
<br>
Name:&nbsp;&nbsp;&nbsp; <input type=”text” name=”name” size=24>
<br>
Date:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type=”text” name=”date” size=24>
<br>
Course:&nbsp;&nbsp;&nbsp;<input type=”text” name=”course-id” size=24>
<br><br>
Please provide your feedback:<br><br>
1. How would you rate the pace of this course:<br>
<input type=”radio” name=”pace” value=”1″>1 – Too slow<br>
<input type=”radio” name=”pace” value=”2″>2<br>
<input type=”radio” name=”pace” value=”3″>3<br>
<input type=”radio” name=”pace” value=”4″>4<br>
<input type=”radio” name=”pace” value=”5″>5 – Too fast<br>
<br><br>
2. Please rate the time spent in the training session:<br>
<input type=”radio” name=”time” value=”1″>1 – Too short<br>
<input type=”radio” name=”time” value=”2″>2<br>
<input type=”radio” name=”time” value=”3″>3<br>
<input type=”radio” name=”time” value=”4″>4<br>
<input type=”radio” name=”time” value=”5″>5 – Too long<br>
<br><br>
3. Was the training session easy to follow?<br>
<input type=”radio” name=”easy” value=”1″>1 – Disagree<br>
<input type=”radio” name=”easy” value=”2″>2<br>
<input type=”radio” name=”easy” value=”3″>3<br>
<input type=”radio” name=”easy” value=”4″>4<br>
<input type=”radio” name=”easy” value=”5″>5 – Agree<br>
<br><br>
4. Clarity of the content:<br>
<input type=”radio” name=”clarity” value=”1″>1 – Confusing<br>
<input type=”radio” name=”clarity” value=”2″>2<br>
<input type=”radio” name=”clarity” value=”3″>3<br>
<input type=”radio” name=”clarity” value=”4″>4<br>
<input type=”radio” name=”clarity” value=”5″>5 – Understandable<br>
<br><br>
5. Was the level of this training:<br>
<input type=”radio” name=”level” value=”1″>1 – Too basic<br>
<input type=”radio” name=”level” value=”2″>2<br>
<input type=”radio” name=”level” value=”3″>3<br>
<input type=”radio” name=”level” value=”4″>4<br>
<input type=”radio” name=”level” value=”5″>5 – Too advanced<br>
<br><br>
6. Did you learn from this style of training?<br>
<input type=”radio” name=”learn” value=”No”>No<br>
<input type=”radio” name=”learn” value=”Yes”>Yes<br>
<br><br>
7. What was your overall impression of the training session?<br>
<input type=”radio” name=”impression” value=”1″>1 – Very poor<br>
<input type=”radio” name=”impression” value=”2″>2<br>
<input type=”radio” name=”impression” value=”3″>3<br>
<input type=”radio” name=”impression” value=”4″>4<br>
<input type=”radio” name=”impression” value=”5″>5 – Excellent<br>
<br><br>
8. Was this training useful to you:<br>
<input type=”radio” name=”useful” value=”1″>1 – Disagree<br>
<input type=”radio” name=”useful” value=”2″>2<br>
<input type=”radio” name=”useful” value=”3″>3<br>
<input type=”radio” name=”useful” value=”4″>4<br>
<input type=”radio” name=”useful” value=”5″>5 – Agree<br>
<br><br>
9. The session met or exceeded your expectations:<br>
<input type=”radio” name=”expectations” value=”1″>1 – Disagree<br>
<input type=”radio” name=”expectations” value=”2″>2<br>
<input type=”radio” name=”expectations” value=”3″>3<br>
<input type=”radio” name=”expectations” value=”4″>4<br>
<input type=”radio” name=”expectations” value=”5″>5 – Agree<br>
<br><br>
10. Would you recommend this course to others?<br>
<input type=”radio” name=”recommend” value=”No”>No<br>
<input type=”radio” name=”recommend” value=”Yes”>Yes<br>
<br><br>
11. Is this course material something that you feel you need more training on?<br>
<input type=”radio” name=”moretraining” value=”No”>No<br>
<input type=”radio” name=”moretraining” value=”Yes”>Yes<br>
<br><br>
What was the most satisfactory aspect of this training?<br>
<textarea name=”mostsatisfactory” rows=”4″ cols=”40″></textarea>
<br><br>
What was the least satisfactory aspect of this training?<br>
<textarea name=”leastsatisfactory” rows=”4″ cols=”40″></textarea>
<br><br>
Are there materials that you would like further training on that were presented in this training
session?<br>
<textarea name=”materials” rows=”4″ cols=”40″></textarea>
<br><br>
Do you think that this training session could be expanded? If so, what additional training topics should
be included?<br>
<textarea name=”expanded” rows=”4″ cols=”40″></textarea>
<br><br>
Do you think this training session will help you in your day-to-day activities?<br>
<textarea name=”help” rows=”4″ cols=”40″></textarea>
<br><br>
Do you think this training session would benefit your entire department?<br>
<textarea name=”department” rows=”4″ cols=”40″></textarea>
<br><br>
How could this training session be improved?<br>
<textarea name=”improve” rows=”4″ cols=”40″></textarea>
<br><br>
Other comments:<br>
<textarea name=”comments” rows=”4″ cols=”40″></textarea><br>
<br><br>
<input type=submit value=”Submit survey”>
</form>
</html>

I have went over it several times. What am I missing? Probably something simple. Not sure if this helps, but there is a little “bang” that pops up in the lower left side of the page next to the word “Done”. When I double click on it, a window pops up that says:
Line: 36
Char: 39
Error: Unterminated String constant
Code:0

Thanks in advance for your help,

Vinny

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@PittimannFeb 02.2005 — Hi!

Almost all the lines dealing with an 'alert("blah")' have line breaks inside the string to be alerted. One of them is also missing the final double quote after the string.

Cheers - Pit
×

Success!

Help @VinnyWolf spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...