I am working on a form that contains multiple checkboxes (each with its own value). The last checkbox is marked "Other" and, when it is checked, a text input should appear to let the user write his/her own value.
<input name="pVital[]" type="checkbox" id="pVital[]" value="I & O" />I & O<br/>
<input name="pVital[]" type="checkbox" id="pVital[]" value="Daily Weight" />Daily Weight<br/>
<input name="pVital[]" type="checkbox" id="pVital[]" value="Foley Catheter" />Foley Catheter<br/>
<input name="pVital[]" type="checkbox" id="pVital[]" onClick="showHide(whatever);" value="" />Other<br/>
<input name="pVital[]" type="text" id="whatever" style="visibility: hidden;" />
I insert all these values into the same field into database, as an array of strings, using php's implode function:
if ((isset($_POST['pVital']))){
$spVital = implode(',',$_POST['pVital']);
}
$insertSQL = sprintf("INSERT INTO admissionorder (VitalSigns) VALUES (%s)",
GetSQLValueString($spVital, "text"));
mysql_select_db($database_PPS, $PPS);
$Result1 = mysql_query($insertSQL, $PPS) or die(mysql_error());
This is working fine for insertion, but I encounter a problem in retrieving these checkboxes... with the "other" text input if appropriate.