[FX.php List] Problem with Javascript validating Checkboxes

Kim Hawksworth Kim.Hawksworth at osumc.edu
Fri Jul 28 06:54:50 MDT 2006


I¹m trying to use Javascript to validate that at least one checkbox from a
checkbox field has been selected.  The checkboxes are being pulled from a
value list in FM8.  The php code that displays the checkboxes on the form
looks like this:

<?php
foreach ($getList ['valueLists']['en_trial_yes_list'] as $key => $value) {
?>
<input type="checkbox" name="en_trial_yes[]" value="<?php echo $value; ?>">
<?php echo $value; ?><br />
<?php
}

The Javascript code I¹m using to validate the checkboxes looks like this:

 var IsEnteralReason = ""
 
  for (var i = 0; i < document.newConsult.en_trial_yes.length; i++) {
  if (document.newConsult.en_trial_yes[i].checked) {
  IsEnteralReason = document.newConsult.en_trial_yes[i].value
  }
      }
      
 if (IsEnteralReason == "") {

 alert ("Please indicate the reason(s) the enteral trial was
unsuccessful!");
 return false;
 }

For the life of me I can¹t get the Javascript to validate this field.  Any
ideas what I¹m doing wrong?

Thanks for your help.

-- 
Kim D. Hawksworth, R.Ph., Web Manager
The Ohio State University Health System
Department of Pharmacy
(614) 293-3765
kim.hawksworth at osumc.edu



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.iviking.org/pipermail/fx.php_list/attachments/20060728/e9787e75/attachment.html


More information about the FX.php_List mailing list