|
dkemas (Programmer) |
26 Apr 12 4:44 |
I think I am getting myself all muddled up with the logic of this, been looking at it for too long now I think. May I start again from scratch? My form runs slightly differently than my poor explanation described and uses some scripts kindly helped on here. There are 10 rows, each row has a dropdown (called *score where * is the number of the row) with values of 3,2,1. If 2 is selected, a checkbox called *pdp is automatically ticked. If 1 is selected, a checkbox called *redflag is automatically ticked. I have this running for all 10 rows. The checkboxes that are automatically ticked must be visible but not modified manually, but also submitted by the form. If 3 checkboxes for *redflag is ticked, then it needs to log this in the database so I have a hidden field that needs to have a value of 1 if three *redflag boxes are ticked. Hope that makes sense. Here's my code as it stands Javacsript CODE<script> //these all tick the pdp and redflag checkboxes based upon the value in the dropdown for that row function FlagTicked1(control) { document.myForm.1pdp.checked = (control.value=="2")? true : false; document.myForm.1redflag.checked = (control.value=="1")? true : false; } function FlagTicked2(control) { document.myForm.2pdp.checked = (control.value=="2")? true : false; document.myForm.2redflag.checked = (control.value=="1")? true : false; } function FlagTicked3(control) { document.myForm.3pdp.checked = (control.value=="2")? true : false; document.myForm.3redflag.checked = (control.value=="1")? true : false; } function FlagTicked4(control) { document.myForm.4pdp.checked = (control.value=="2")? true : false; document.myForm.4redflag.checked = (control.value=="1")? true : false; } function FlagTicked5(control) { document.myForm.5pdp.checked = (control.value=="2")? true : false; document.myForm.5redflag.checked = (control.value=="1")? true : false; } function FlagTicked6(control) { document.myForm.6pdp.checked = (control.value=="2")? true : false; document.myForm.6redflag.checked = (control.value=="1")? true : false; } function FlagTicked7(control) { document.myForm.7pdp.checked = (control.value=="2")? true : false; document.myForm.7redflag.checked = (control.value=="1")? true : false; } function FlagTicked8(control) { document.myForm.8pdp.checked = (control.value=="2")? true : false; document.myForm.8redflag.checked = (control.value=="1")? true : false; } function FlagTicked9(control) { document.myForm.9pdp.checked = (control.value=="2")? true : false; document.myForm.9redflag.checked = (control.value=="1")? true : false; } function FlagTicked10(control) { document.myForm.10pdp.checked = (control.value=="2")? true : false; document.myForm.10redflag.checked = (control.value=="1")? true : false; } </script> Form CODE<form method='post' action='form.php' id='myForm' name='myForm'> <input type='hidden' name='redflagnotify' value='' /> <!-- this needs to be value='1' if there are 3 redflags checked -->
<table> <tr> <th>Code</th> <th>Question</th> <th>Score</th> <th>Witnessed</th> <th>PDP</th> <th>Red Flag</th> </tr>
<tr> <td>111</td> <td>Question 1</td> <td> <select name='1score' onchange="FlagTicked1(this)"> <option value=''>- Please select -</option> <option selected="selected" value='3'>3</option> <option value='2'>2</option> <option value='1'>1</option> </select> </td> <td><input type='checkbox' name='1witnessed' value='1' /></td> <td><input type='checkbox' name='1pdp' value='1' onclick="return false" onkeydown="return false" class='disabled' /></td> <td><input type='checkbox' name='1redflag' value='1' onclick="return false" onkeydown="return false" class='disabled' /></td> </tr>
<tr> <td>222</td> <td>Question 2</td> <td> <select name='2score' onchange="FlagTicked2(this)"> <option value=''>- Please select -</option> <option selected="selected" value='3'>3</option> <option value='2'>2</option> <option value='1'>1</option> </select> </td> <td><input type='checkbox' name='2witnessed' value='1' /></td> <td><input type='checkbox' name='2pdp' value='1' onclick="return false" onkeydown="return false" class='disabled' /></td> <td><input type='checkbox' name='2redflag' value='1' onclick="return false" onkeydown="return false" class='disabled' /></td> </tr>
<tr> <td>333</td> <td>Question 3</td> <td> <select name='3score' onchange="FlagTicked3(this)"> <option value=''>- Please select -</option> <option selected="selected" value='3'>3</option> <option value='2'>2</option> <option value='1'>1</option> </select> </td> <td><input type='checkbox' name='3witnessed' value='1' /></td> <td><input type='checkbox' name='3pdp' value='1' onclick="return false" onkeydown="return false" class='disabled' /></td> <td><input type='checkbox' name='3redflag' value='1' onclick="return false" onkeydown="return false" class='disabled' /></td> </tr>
<!-- etc etc up to 10 -->
</table> |
|