In my current project I need to display a question to the user in the form of Check all that apply. Naturally the formCheckbox helper is used.
I also need to 'attach' some javascript code whereas when I click on a particular checkbox the javascript would disable the remaining checkboxes.
Everything is fine in Firefox but not in IE. I discovered that the hidden field with the same name that is added prior to the checkbox HTML code is what is causing the problem. On Firefox the correct value is picked up, since the data is parsed as a single array so by defining an element with the same name, Firefox would use the last value. It appears though that IE would use the first element value.
I played around a bit and moved the hidden element at the end of the code generation so now my checkbox is first. That made the code work in IE and stop working in Firefox...
The element generation is as follows ($data is the array that contains the checkbox descriptions that I need to print; noneOTA is a javascript function that disables all the other checkboxes):
foreach ($data as $key => $item) {
$name = 'evl05_' . $key;
unset($attribs);
$attribs['class'] = 'inputRadio';
$attribs['onchange'] = "noneOTA('evl05_', '{$last}');";
if ($item['description']) {
$legend[] = "<strong>{$item['service']}:</strong> "
. "{$item['description']}";
}
if (isItemChecked($dataArray, $name)) {
$attribs['checked'] = true;
}
$value = isItemChecked($dataArray, $name);
$elements['evl05'] .= "
<tr>
<td style='width: 5px; text-align: center; vertical-align: top;'>
" . $view->formCheckbox($name, null, $attribs) . "
</td>
<td style='vertical-align: top;'>
{$item['service']}
</td>
</tr>";
}
Has anyone come across this issue before? Any pointers would be greatly appreciated.
Thanks
Nikos
--
The contents of this message may contain confidential or privileged information and is intended solely for the recipient(s). Use or distribution to and by any other party is not authorized. If you are not the intended recipient, copying, distribution or use of the contents of this information is prohibited.
没有评论:
发表评论