[Zope3-checkins] SVN: zope.formlib/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
Tue Nov 1 19:53:23 EST 2005
Log message for revision 39839:
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
Changed:
U zope.formlib/trunk/src/zope/formlib/pageform.pt
U zope.formlib/trunk/src/zope/formlib/subpageform.pt
-=-
Modified: zope.formlib/trunk/src/zope/formlib/pageform.pt
===================================================================
--- zope.formlib/trunk/src/zope/formlib/pageform.pt 2005-11-02 00:15:33 UTC (rev 39838)
+++ zope.formlib/trunk/src/zope/formlib/pageform.pt 2005-11-02 00:53:22 UTC (rev 39839)
@@ -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: zope.formlib/trunk/src/zope/formlib/subpageform.pt
===================================================================
--- zope.formlib/trunk/src/zope/formlib/subpageform.pt 2005-11-02 00:15:33 UTC (rev 39838)
+++ zope.formlib/trunk/src/zope/formlib/subpageform.pt 2005-11-02 00:53:22 UTC (rev 39839)
@@ -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