JohnJava
02-17-2004, 11:22 PM
Hi all, I want to know how to produce the result in ASP, since I don't have any idea in this part.
What I want ASP to do to me is to get the no. of checkbox checked, for instance, if the user check the checkbox no.2 and chekbox number no.3 in Stage 1(Question 1), then the ASP will calculate (answer=2*3*1) where no.2 is checkbox no.2, 3 is checkbox no.3, and no.1 is Question no.1 or Stage 1. Lastly, I want it reply the total to HTML. Please Help me...
Below is example coding that I created in HTML
<html>
<head>
<title>Survey</title>
<script type="text/javascript">
var nq = 2 //input number of questions
var nc = 3 //input the number of checkboxes on a question
var x
function check(a)
{ c = new Array()
for(i=0; i<nc; i++){
c[i] = document.forms[0].elements[a.name][i].checked
if(c[i] == true){x = i}}
n = new Array()
for(j=0; j<nq*nc; j++){
n[j] = document.forms[0].elements[j].name
for (i=0; i<nc; i++){
if (i==x){document.forms[0].elements[n[j]][i].disabled = true}}}}
function refresh()
{location.reload()}
</script>
</head>
<body>
<form action ="process.asp" id="process" name="process">
<b>Stage 1</b><table border="1" cellpadding="0" cellspacing="0"
style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
<tr><td width="100%"><input name="q0" type="checkbox" onclick="check(this)" value="ON"></td></tr>
<tr><td width="100%"><input name="q0" type="checkbox" onclick="check(this)" value="ON"></td></tr>
<tr> <td width="100%"><input name="q0" type="checkbox" onclick="check(this)" value="ON"></td></tr>
</table>
<p><br>
<b>Stage 2<br> </b>
<table border="1" cellpadding="0" cellspacing="0"
style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber2">
<tr><td width="100%"><input name="q1" type="checkbox" onclick="check(this)" value="ON"></td></tr>
<tr><td width="100%"><input name="q1" type="checkbox" onclick="check(this)" value="ON"></td></tr>
<tr><td width="100%"><input name="q1" type="checkbox" onclick="check(this)" value="ON"></td></tr>
</table>
<input type="reset" value="Reset" name="cmdSubmit" onclick="refresh()">
<input type="submit" value="Submit" name="cmdSubmit">
</form>
</body>
</html>
What I want ASP to do to me is to get the no. of checkbox checked, for instance, if the user check the checkbox no.2 and chekbox number no.3 in Stage 1(Question 1), then the ASP will calculate (answer=2*3*1) where no.2 is checkbox no.2, 3 is checkbox no.3, and no.1 is Question no.1 or Stage 1. Lastly, I want it reply the total to HTML. Please Help me...
Below is example coding that I created in HTML
<html>
<head>
<title>Survey</title>
<script type="text/javascript">
var nq = 2 //input number of questions
var nc = 3 //input the number of checkboxes on a question
var x
function check(a)
{ c = new Array()
for(i=0; i<nc; i++){
c[i] = document.forms[0].elements[a.name][i].checked
if(c[i] == true){x = i}}
n = new Array()
for(j=0; j<nq*nc; j++){
n[j] = document.forms[0].elements[j].name
for (i=0; i<nc; i++){
if (i==x){document.forms[0].elements[n[j]][i].disabled = true}}}}
function refresh()
{location.reload()}
</script>
</head>
<body>
<form action ="process.asp" id="process" name="process">
<b>Stage 1</b><table border="1" cellpadding="0" cellspacing="0"
style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
<tr><td width="100%"><input name="q0" type="checkbox" onclick="check(this)" value="ON"></td></tr>
<tr><td width="100%"><input name="q0" type="checkbox" onclick="check(this)" value="ON"></td></tr>
<tr> <td width="100%"><input name="q0" type="checkbox" onclick="check(this)" value="ON"></td></tr>
</table>
<p><br>
<b>Stage 2<br> </b>
<table border="1" cellpadding="0" cellspacing="0"
style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber2">
<tr><td width="100%"><input name="q1" type="checkbox" onclick="check(this)" value="ON"></td></tr>
<tr><td width="100%"><input name="q1" type="checkbox" onclick="check(this)" value="ON"></td></tr>
<tr><td width="100%"><input name="q1" type="checkbox" onclick="check(this)" value="ON"></td></tr>
</table>
<input type="reset" value="Reset" name="cmdSubmit" onclick="refresh()">
<input type="submit" value="Submit" name="cmdSubmit">
</form>
</body>
</html>