My thinking is, as I said. Since the functionality as regards the hidden fields appears to rely upon the names being as is, it is the id's that should be changed. They should be different than the names. This will require wholesale changes in the markup. Like the id for:
Code:
<input id='question_18_B_1'
could become, say:
Code:
<input id='ask_18_B_1'
So for that you could do a global change of all the files, changing:
id='question
to:
id='ask
In the script I think you are OK because you address the id thus:
so it will pick up and use the new id's automatically. However, where you have:
Code:
// doing B
var B_Name = Name+'_B_';
if(document.getElementById(Id).value != 1){
and similar, it will now have to be:
Code:
// doing B
var B_Name = Id.replace(/_\d$/, '')+'_B_';
if(document.getElementById(Id).value != 1){
It should then all work out. I'll test this theory, as I may be missing something else that needs to be changed.
For example:
Code:
<script type="text/javascript">
function makeChoice(obj)
{
var Name = obj.name;
var Id = obj.id;
//alert(Id);
// doing B
var B_Name = Id.replace(/_\d$/, '')+'_B_';
if(document.getElementById(Id).value != 1){
for(var x=1; x<10; x++){
if(document.getElementById(B_Name+x)){
document.getElementById(B_Name+x).disabled = true;
}
}
}
else
{
for(var x=1; x<10; x++){
if(document.getElementById(B_Name+x)){
document.getElementById(B_Name+x).disabled = false;
}
}
}
// doing C
var C_Name = Id.replace(/_\d$/, '')+'_C_';
if(document.getElementById(Id).value != 1){
for(var x=1; x<14; x++)
if(document.getElementById(C_Name+x)){
document.getElementById(C_Name+x).disabled = true;
}
}else{
for(var x=1; x<14; x++)
if(document.getElementById(C_Name+x)){
document.getElementById(C_Name+x).disabled = false;
}
}
}
</script>
<form id='page3' name='page3' method='post' action=test.php'>
<table width='100%'>
<tr>
<td align='center' height='50px'>
<input id='ask_18_1' name='question_18' type='radio' onclick='makeChoice(this);' value='1' /></td>
<td align='center' height='50px'>
<input id='ask_18_2' name='question_18' type='radio' onclick='makeChoice(this);' value='2' /></td>
</tr>
</table>
<table>
<tr>
<td height ='50px' align='center'>
<input id='ask_18_B_1' name='question_18_B_1' type='checkbox' value='1' disabled="disabled" /></td>
<td height ='50px' align='center'>
<input id='ask_18_B_2' name='question_18_B_2' type='checkbox' value='1' disabled="disabled" /></td>
</tr>
<tr>
<td height ='70px' align='center'><input type='hidden' name='question_18_C_1' value='0'>
<input id='ask_18_C_1' name='question_18_C_1' type='checkbox' value='1' disabled="disabled" /></td>
<td height ='70px' align='center'><input type='hidden' name='question_18_C_2' value='0'>
<input id='ask_18_C_2' name='question_18_C_2' type='checkbox' value='1' disabled="disabled" /></td>
</tr>
</table>
<input id='submitpage3' type='submit' name='submit' value='Page suivante' />
Bookmarks