Javascript on ASP Survey Page

M

maliks

I am trying to use Javascript on a ASP survey page and for some reason
my Javascript code is not working. Please see survey link below:
http://www.scif.com/SFO/Survey/SelfRegistration.asp

Question # 5 on the survey gives the user to choose from one of the
radio buttons YES or NO and then gives an option of FIVE checkboxes
below that.

Does anyone know how can I get the survey to work in such a way that if
the user clicks on radio button NO on question # 5 in the survey,
he/she does not have the option of clicking on any of the five check
boxes. Only if he clicks on the radio button YES, should he be able to
click on any of the five check boxes below. Presently, wether user
clicks on radio button yes or no, he is able to check all the check
boxes. I wrote a script on the survey ASP page, but it does not seem to
work. It would be great if someone could tell me what am I doing wrong.
Please see code for ASP page/javascript below:
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/myConnection.asp" -->
<%
' *** Edit Operations: declare variables

Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd

Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId

Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i

MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" &
Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
MM_abortEdit = false

' query string to execute
MM_editQuery = ""
%>
<%
' *** Insert Record: set variables

If (CStr(Request("MM_insert")) = "form1") Then

MM_editConnection = MM_myConnection_STRING
MM_editTable = "dbo.SelfRegSurvey"
MM_editRedirectUrl = "survey_ack.asp"
MM_fieldsStr =
"connection|value|userTypeOther|value|ComputerSkills|value|EaseOfUse|value|Tutorials|value|Version|value|FlashVersion|value|HelpfulYes|value|WhyYes|value|HelpfulNo|value|WhyNo|value|InfoFindProblems|value|ProblemDec|value|ProblemARE|value|ProblemGrpNum|value|ProblemPolNum|value|ProblemSignDt|value|ProblemDOCode|value|CompletionTime|value|UserComments|value"
MM_columnsStr =
"howConnect|',none,''|howOtherConnect|',none,''|computerSkills|',none,''|easeOfUse|none,none,NULL|viewTutorials|',none,''|whichVersion|',none,''|versionFlash|',none,''|tutorialHelpfulYes|',none,''|yesExplain|',none,''|tutorialHelpfulNo|',none,''|noExplain|',none,''|problemInformation|',none,''|prDeclarationPage|none,1,0|prARE|none,1,0|prGroupNumber|none,1,0|prPolicyNumber|none,1,0|prCountersign|none,1,0|prDistrictcode|none,1,0|howMuchTime|',none,''|additionalComments|',none,''"

' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")

' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
Next

' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And
Request.QueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" &
Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" &
Request.QueryString
End If
End If

End If
%>
<%
' *** Insert Record: construct a sql insert statement and execute it

Dim MM_tableValues
Dim MM_dbValues

If (CStr(Request("MM_insert")) <> "") Then

' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),",")
MM_delim = MM_typeArray(0)
If (MM_delim = "none") Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none") Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none") Then MM_emptyVal = ""
If (MM_formVal = "") Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "") Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'") Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End If
MM_tableValues = MM_tableValues & MM_columns(MM_i)
MM_dbValues = MM_dbValues & MM_formVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues
& ") values (" & MM_dbValues & ")"

If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If

End If
%>
<%
Dim rsSurvey
Dim rsSurvey_numRows

Set rsSurvey = Server.CreateObject("ADODB.Recordset")
rsSurvey.ActiveConnection = MM_myConnection_STRING
rsSurvey.Source = "SELECT * FROM dbo.SelfRegSurvey"
rsSurvey.CursorType = 0
rsSurvey.CursorLocation = 2
rsSurvey.LockType = 1
rsSurvey.Open()

rsSurvey_numRows = 0
%>
<head>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>Untitled Document</title>
<!-- Hide script from older browsers
<script language="Javascript"
type="text/javascript">

function disableBoxes(state){
for(i=1;i<6;i++){
document.getElementById("checkbox"+i).enabled =
(state == false)?"disabled":"enabled:;
}
</script>
//End hiding script -->
</head>
<body>
<h2>Self Registration Survey </h2>
<p>In our efforts to provide the best possible service to you, we would
like to know your thoughts about the Self-Registration process. Please
take a moment to complete this survey. Your feedback is very important
to us.</p>
<form ACTION="<%=MM_editAction%>" METHOD="POST" name="form1"
id="form1">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<td width="7%">&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr valign="top">
<td>1.</td>
<td>What type of connection do you use to access the Internet?<br
/>
<input name="connection" type="radio" value="dial-Up" />
Dial-up<br />
<input name="connection" type="radio" value="cable/dsl" />
Cable/DSL <br />
<input name="connection" type="radio" value="other" />
Other, please specify:
<input name="userTypeOther" type="text" id="userTypeOther2"
/></td>
</tr>
<tr valign="top">
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr valign="top">
<td>2.</td>
<td>How would you rate your computer skills?<br />
<input name="ComputerSkills" type="radio" value="novice" />

Novice
<input name="ComputerSkills" type="radio" value="average" />
Average
<input name="ComputerSkills" type="radio" value="above average"
/>
Above average
<input name="ComputerSkills" type="radio" value="expert" />
Expert</td>
</tr>
<tr valign="top">
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr valign="top">
<td height="31">3.</td>
<td>How easy was it to use the Self-Registration process?<br />
Easy
<input name="EaseOfUse" type="radio" value="1" />
1
<input name="EaseOfUse" type="radio" value="2" />
2
<input name="EaseOfUse" type="radio" value="3" />
3
<input name="EaseOfUse" type="radio" value="4" />
4
<input name="EaseOfUse" type="radio" value="5" />
5 Difficult</td>
</tr>
<tr valign="top">
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr valign="top">
<td>4.</td>
<td><p>Did you view the Self-Registration tutorials?<br />
<input name="Tutorials" type="radio" value="yes" />
Yes
<input name="Tutorials" type="radio" value="no" />
No </p>
<p> If yes, which version?<br />
<input name="Version" type="radio" value="Flash" />
Flash
<input name="Version" type="radio" value="PDF" />
PDF</p>
<p> If you viewed the Flash tutorial, which version did you
use?<br />
<input name="FlashVersion" type="radio" value="Sound" />
Sound
<input name="FlashVersion" type="radio" value="Text" />
Text</p>
<p>Did you find the tutorial helpful?<br />
<input name="HelpfulYes" type="radio" value="Yes" />
Yes<br />
If yes, please explain: <br />
<textarea name="WhyYes" cols="28" rows="3"
id="textarea"></textarea>
</p>
<p>
<input name="HelpfulNo" type="radio" value="No" />
No <br />
If no, please explain: <br />
<textarea name="WhyNo" cols="28" rows="3"
id="WhyNo"></textarea>
</p></td>
</tr>
<tr valign="top">
<td>&nbsp; </td>
</tr>
<tr valign="top">
<td>5.</td>
<td>

<p>Did you have any problems finding any of the information or
documents required to complete the Self-Registration process?<br />
<input name="InfoFindProblems" type="radio" value="yes" />
Yes
<input name="InfoFindProblems" type="radio" value="no"
onChange="disableBoxes(this.checked)" />
No</p>
<p> If yes, please indicate which (select all that apply): <br
/>

Declaration page <br />
<input name="ProblemARE" type="checkbox" id="ProblemARE"
value="checkbox" />
Annual Rating Endorsement [A.R.E.] <br />
<input name="ProblemGrpNum" type="checkbox"
id="ProblemGrpNum" value="checkbox" />
Group Number <br />
<input name="ProblemPolNum" type="checkbox"
id="ProblemPolNum" value="checkbox" />
Policy Number<br />
<input name="ProblemSignDt" type="checkbox"
id="ProblemSignDt" value="checkbox" />
Countersign Date<br />
<input name="ProblemDOCode" type="checkbox"
id="ProblemDOCode" value="checkbox" />
District Office Code </p></td>
</tr>
<tr valign="top">
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr valign="top">
<td>6.</td>
<td><span>How much time did it take you to self-register?<br />
</span>
<input name="CompletionTime" type="radio" value="0-5" />
<span> 0-5 minutes<br />
<input name="CompletionTime" type="radio" value="6-10" />
6-10 minutes<br />
<input name="CompletionTime" type="radio" value="11-15" />
11-15 minutes</span><br />
<input name="CompletionTime" type="radio" value="over-15" />
<span>More than 15 minutes </span></td>
</tr>
<tr valign="top">
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr valign="top">
<td>7.</td>
<td><p>Please feel free to provide us with any additional
comments regarding the Self-Registration process:<br />
<textarea name="UserComments" cols="28" rows="3"
id="UserComments"></textarea>
</p>
<p>&nbsp;</p></td>
</tr>
<tr valign="top">
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr valign="top">
<td>&nbsp;</td>
<td>
<div align="left">
<input name="Submit" type="submit" value="Submit Survey" />
</div></td>
</tr>
</table>





<input type="hidden" name="MM_insert" value="form1">
</form>
</body>
</html>
<%
rsSurvey.Close()
Set rsSurvey = Nothing
%>

Thanks
~Nish
 
L

Lee

(e-mail address removed) said:
I am trying to use Javascript on a ASP survey page

If you're asking a Javascript question, it doesn't matter whether
the page is generated by ASP, PHP, CGI, or Notepad.


Question # 5 on the survey gives the user to choose from one of the
radio buttons YES or NO and then gives an option of FIVE checkboxes
below that.

Does anyone know how can I get the survey to work in such a way that if
the user clicks on radio button NO on question # 5 in the survey,
he/she does not have the option of clicking on any of the five check
boxes.
...
Please see code for ASP page/javascript below:

Please don't post your ASP code. It's not relevent.
<!-- Hide script from older browsers
<script language="Javascript"
type="text/javascript">

function disableBoxes(state){
for(i=1;i<6;i++){
document.getElementById("checkbox"+i).enabled =
(state == false)?"disabled":"enabled:;
}
</script>
//End hiding script -->


Get rid of the lines that refer to hiding script.
They haven't been needed for several years, and could cause
trouble, particularly since they're misplaced.

That function attempts to set the "enabled" attribute of page
elements with ID values "checkbox1" through "checkbox5".
Those are not the ID values of the boxes you're trying to
enable/disable, and if they were, it still wouldn't work,
because the checkbox does not have an attribute named "enabled".
It has one of the opposite sense: "disabled".



<td>5.</td>
<td>

<p>Did you have any problems finding any of the information or
documents required to complete the Self-Registration process?<br />
<input name="InfoFindProblems" type="radio" value="yes" />
Yes
<input name="InfoFindProblems" type="radio" value="no"
onChange="disableBoxes(this.checked)" />
No</p>
<p> If yes, please indicate which (select all that apply): <br
/>

Declaration page <br />
<input name="ProblemARE" type="checkbox" id="ProblemARE"
value="checkbox" />
Annual Rating Endorsement [A.R.E.] <br />
<input name="ProblemGrpNum" type="checkbox"
id="ProblemGrpNum" value="checkbox" />
Group Number <br />
<input name="ProblemPolNum" type="checkbox"
id="ProblemPolNum" value="checkbox" />
Policy Number<br />
<input name="ProblemSignDt" type="checkbox"
id="ProblemSignDt" value="checkbox" />
Countersign Date<br />
<input name="ProblemDOCode" type="checkbox"
id="ProblemDOCode" value="checkbox" />
District Office Code </p></td>
</tr>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,058
Latest member
QQXCharlot

Latest Threads

Top