I have a dynamic build selection list. The selection list holds "Permit" strings what the user adds to a selection list before recording the form data.
I would like to save all the values of the select box to a string, selected or not selected. Can someone pl explain how would I proceed iterating through the selection box and appending to a string all option values of the dynamicly created selection?
thank you for your smarts and time
function PermitAdd() {
var formObject = document.frmJob
if (formObject.TxtPermitNr.value!="" && formObject.TxtPermitNr.value!="") {
addOption(formObject.lstPermits,formObject.TxtPermitNr.value,formObject.TxtPermitNr.value)
} else {
alert("Fill permit text field ")
}
}
....
<tr>
<td width="25%">Permit #: </td>
<td width="9%"><input name="TxtPermitNr" type="text" id="TxtPermitNr" value="<?php echo $strTxtPermitNr;?>" size="10" maxlength="20" /> </td>
<td width="10%"><input name="button2" type="button" onclick="PermitAdd()" value="Add"/></td>
<td width="16%"><div align="center">
<select name="lstPermits" size="4" multiple="multiple" id="lstPermits">
</select>
</div></td>
<td width="40%"><input name="button" type="button" onclick="PermitDelete()" value="Del"/></td>
</tr>
...
now in my php code where I save the form to the database i would like to have a string of all the values in lstPermits
$strTxtPermitArr[] = trim($_POST['lstPermits']);
foreach($strTxtPermitArr as $key => $value){
$strTxtPermitNr .= $key ." - " . $value ." ";
}