我在页面中创建了一个静态选项列表,我想使用 JavaScript 而不是 AJAX 进行验证:
<?php echo $form->labelEx($model,'emlevel'); ?>
<?php
echo $form->radioButtonList($model,'emlevel',
array('L'=>'Low','M'=>'Moderate','X'=>'Low Moderate', 'H'=>'High'),
array('separator' => " " ));
?>
<?php echo $form->error($model,'emlevel'); ?>
function chk()
{
// first I checked the value for emlevel to verify it get the value or not
//but it shows undefined
alert (document.forms["ConsultationNew"] ["ConsultationNew[enc_type]"].value);
if (document.forms["ConsultationNew"]["ConsultationNew[emlevel]"].value == null) {
alert ('choose one EMlevel'); return false;
}
}
我无法通过document.getelement
....value 获得价值。表明undefined