Click to See Complete Forum and Search --> : What happen to my Codes..


JohnJava
02-18-2004, 09:46 PM
Please check for me... maybe it isn't so hard for you. I've no idea....

<html>

<head>
<script type="text/javascript">

function check(a)
{
var nq = 6 //input number of questions
var nc = 6 //input the number of checkboxes on a question
var x
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 countCheckboxes(a) {
var obj;
var total;
var count = 0;
for (var i=0; i<a.elements.length; i++)
{
obj = a.elements[i];
if (obj.name == "q0" && obj.checked)
{ count++;}
}
total=count*3
alert("Total is " + total);
}

function refresh()
{ location.reload()}

</script>

</head>

<body>
<form>

<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>
<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>&nbsp;</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>
<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>
<p><br>

<b>Stage 3<br>&nbsp;</b><table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber2">
<tr>
<td width="100%">
<input name="q2" type="checkbox" onclick="check(this)" value="ON"></td>
</tr>
<tr>
<td width="100%">
<input name="q2" type="checkbox" onclick="check(this)" value="ON"></td>
</tr>
<tr>
<td width="100%">
<input name="q2" type="checkbox" onclick="check(this)" value="ON"></td>
</tr>
<tr>
<td width="100%">
<input name="q2" type="checkbox" onclick="check(this)" value="ON"></td>
</tr>
<tr>
<td width="100%">
<input name="q2" type="checkbox" onclick="check(this)" value="ON"></td>
</tr>
<tr>
<td width="100%">
<input name="q2" type="checkbox" onclick="check(this)" value="ON"></td>
</tr>
</table>
<p><br>

<b>Stage 4<br>&nbsp;</b><table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber2">
<tr>
<td width="100%">
<input name="q3" type="checkbox" onclick="check(this)" value="ON"></td>
</tr>
<tr>
<td width="100%">
<input name="q3" type="checkbox" onclick="check(this)" value="ON"></td>
</tr>
<tr>
<td width="100%">
<input name="q3" type="checkbox" onclick="check(this)" value="ON"></td>
</tr>
<tr>
<td width="100%">
<input name="q3" type="checkbox" onclick="check(this)" value="ON"></td>
</tr>
<tr>
<td width="100%">
<input name="q3" type="checkbox" onclick="check(this)" value="ON"></td>
</tr>
<tr>
<td width="100%">
<input name="q3" type="checkbox" onclick="check(this)" value="ON"></td>
</tr>
</table>
<p><br>

<b>Stage 5<br>&nbsp;</b><table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber2">
<tr>
<td width="100%">
<input name="q4" type="checkbox" onclick="check(this)" value="ON"></td>
</tr>
<tr>
<td width="100%">
<input name="q4" type="checkbox" onclick="check(this)" value="ON"></td>
</tr>
<tr>
<td width="100%">
<input name="q4" type="checkbox" onclick="check(this)" value="ON"></td>
</tr>
<tr>
<td width="100%">
<input name="q4" type="checkbox" onclick="check(this)" value="ON"></td>
</tr>
<tr>
<td width="100%">
<input name="q4" type="checkbox" onclick="check(this)" value="ON"></td>
</tr>
<tr>
<td width="100%">
<input name="q4" type="checkbox" onclick="check(this)" value="ON"></td>
</tr>
</table>
<p><br>

<b>Stage 6<br>&nbsp;</b><table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber2">
<tr>
<td width="100%">
<input name="q5" type="checkbox" onclick="check(this)" value="ON"></td>
</tr>
<tr>
<td width="100%">
<input name="q5" type="checkbox" onclick="check(this)" value="ON"></td>
</tr>
<tr>
<td width="100%">
<input name="q5" type="checkbox" onclick="check(this)" value="ON"></td>
</tr>
<tr>
<td width="100%">
<input name="q5" type="checkbox" onclick="check(this)" value="ON"></td>
</tr>
<tr>
<td width="100%">
<input name="q5" type="checkbox" onclick="check(this)" value="ON"></td>
</tr>
<tr>
<td width="100%">
<input name="q5" type="checkbox" onclick="check(this)" value="ON"></td>
</tr>
</table>
<p><br>


<input type="reset" value="Reset" onclick="refresh()">
<input type="button" value="Count" onclick="countCheckboxes(1)">

</form>
</body>

</html>

buntine
02-18-2004, 10:26 PM
huh? What do you want us to do?