[Zope3-checkins] SVN: Zope3/trunk/src/zope/formlib/ avoid some of
the JavaScript errors; forms that contain more than one field
Fred L. Drake, Jr.
fdrake at gmail.com
Thu Nov 3 11:01:28 EST 2005
Log message for revision 39875:
avoid some of the JavaScript errors; forms that contain more than one field
of a given name (such as checkboxes or radio buttons) can provide a NodeList
instead of a single input object; that needs to be handled specially
use "field.length == null" instead of "field instanceof NodeList" since
(appearantly) NodeList is in different namespace on different browsers, or
doesn't exist on MSIE
Changed:
U Zope3/trunk/src/zope/formlib/pageform.pt
U Zope3/trunk/src/zope/formlib/subpageform.pt
-=-
Modified: Zope3/trunk/src/zope/formlib/pageform.pt
===================================================================
--- Zope3/trunk/src/zope/formlib/pageform.pt 2005-11-03 15:57:31 UTC (rev 39874)
+++ Zope3/trunk/src/zope/formlib/pageform.pt 2005-11-03 16:01:28 UTC (rev 39875)
@@ -20,7 +20,16 @@
// ob is the label element
var field = ob.form[ob.htmlFor];
if (field) {
- field.style.visibility = state && 'hidden' || 'visible';
+ var viz = state && 'hidden' || 'visible';
+ if (field.length == null) {
+ field.style.visibility = viz;
+ }
+ else {
+ for (var i = 0; i < field.length; ++i) {
+ var e = field.item(i);
+ e.style.visibility = viz;
+ }
+ }
var help = document.getElementById("field-help-for-" + field.name);
if (help) {
help.style.visibility = state && 'visible' || 'hidden';
Modified: Zope3/trunk/src/zope/formlib/subpageform.pt
===================================================================
--- Zope3/trunk/src/zope/formlib/subpageform.pt 2005-11-03 15:57:31 UTC (rev 39874)
+++ Zope3/trunk/src/zope/formlib/subpageform.pt 2005-11-03 16:01:28 UTC (rev 39875)
@@ -7,7 +7,16 @@
// ob is the label element
var field = ob.form[ob.htmlFor];
if (field) {
- field.style.visibility = state && 'hidden' || 'visible';
+ var viz = state && 'hidden' || 'visible';
+ if (field.length == null) {
+ field.style.visibility = viz;
+ }
+ else {
+ for (var i = 0; i < field.length; ++i) {
+ var e = field.item(i);
+ e.style.visibility = viz;
+ }
+ }
var help = document.getElementById("field-help-for-" + field.name);
if (help) {
help.style.visibility = state && 'visible' || 'hidden';
More information about the Zope3-Checkins
mailing list