Right have got a form working fine with various textboxes etc on my form all working fine and when submitted they are emailed to me. All fine.
Anyway I have now got a couple of select boxes, they are for a removal company. The user selects if they need moving i.e. one selection box is 2 seater sofa and the other selection box is 3 seater sofa. If the user needs these moving they select a checkbox and they can enter the quantity in the selection. This all works see the code below
Code: Select all
<li class="span-7">
<label for="2_sofa">2 Seater Sofa:</label>
<input type="checkbox" name="chk1" value="1" OnClick="fncEnable(1)">
<label for="2_sofa">Quantity</label>
<select id="txt1" name="txt1" value="" DISABLED CLASS="disabledclass" />
<option value=" " >- Please select -</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
</li>
<li class="span-7 last">
<label for="3_sofa">3 Seater Sofa:</label>
<input type="checkbox" name="chk2" value="2" OnClick="fncEnable(2)">
<label for="3_sofa">Quantity:</label>
<select id="txt2" name="txt2" value="" DISABLED CLASS="disabledclass" />
<option value=" " >- Please select -</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
</li>This is handled with javascript with the following code
Code: Select all
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
function fncEnable(chknum)
{
if(document.frm["chk"+chknum].checked == true)
{
document.frm["txt"+chknum].className = 'enabledclass';
document.frm["txt"+chknum].disabled = false;
}
else
{
document.frm["txt"+chknum].className = 'disabledclass';
document.frm["txt"+chknum].value = '';
document.frm["txt"+chknum].disabled = true;
}
}
//-->
</SCRIPT>I think it needs to be in a loop like the following but I am stuck. Any ideas??
Code: Select all
for ($i = 0; $i < $numberOfCheckboxes; $i++) {
if (isset($_POST['chk' . $i])) {
$items = trim($_POST['txt' . $i]);
}
}