|
#1
|
|||
|
|||
|
I came across a bug while implementing my field copy script. On a particular form I kept getting an "undefined error". I also noticed that the values in the editable fields were all offset from the way they should have rendered (i.e. the bottom value in the top field). After some head scratching I discovered the deviant. It is the <fieldset></fieldset> tag. Javascript sees it as a form element but doesn't seem to know what it is. The element.type method returns "undefined". I cannot find anything about this in the JS documentation. Anybody know how to deal with this problem?
If I cannot find a way to trap out the errant object then I'll have no choice but to stop using <fieldset> in my forms. Thanks! Ruberto |
|
#2
|
||||
|
||||
|
On what browser?
__________________
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP! |
|
#3
|
||||
|
||||
|
element.type doesn't say what an element is. typeof element declares what it is, if type == null, it will obviously return an error.
|
|
#4
|
||||
|
||||
|
If one has:
Code:
<input type="password" id="pass">
__________________
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP! |
|
#5
|
||||
|
||||
|
I think the OP got the wrong impression of the "type" attribute. He/she probably thought it was a method which returned a value of what type the element being tested was. Again, a simple error
|
|
#6
|
||||
|
||||
|
By the way, there isn't any ways to dynamically change the "type" attribute, that I know of.
|
|
#7
|
||||
|
||||
|
Quote:
Admittedly it's a property, not a method, but I don't think Ruberto has the wrong idea.
__________________
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP! |
|
#8
|
||||
|
||||
|
Quote:
Code:
if (element.type||(element.tagName&&element.tagName.toLowerCase()=='fieldset')) Code:
if (element.type&&(element.tagName&&element.tagName.toLowerCase()!='fieldset')) Other tests can be devised to deal with fieldsets in whatever way you decide that you need to.
__________________
WWWWWWWWWWWW - John________________________ Really Show Your Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate |
|
#9
|
||||
|
||||
|
I'd still like to know in what browser(s) this occurs.
__________________
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP! |
|
#10
|
|||
|
|||
|
The code is here in another thread:
http://www.dynamicdrive.com/forums/s...ad.php?t=17078 You'll need to put the code on a page with a form containing an equal number of hidden and editable form elements. Uncomment the line with //alert(widgetType) which you'll see in the new populateFields() function at the bottom of the posting. You may use this page for a test but it does not have the new populateFields() function. http://frankentron.freezope.org/update.html I guess it isn't necessary you can use that version the way it is but add some <fieldset> tags and add the line to popup the value of the widgetType variable. The <fieldset> tag makes the script break in both Firefox and IE. Twey is right I mistakenly wrote method when I should have said property. I like John's idea for dealing with this problem, I'm gona give that a try. Thanks everyone for the help and instruction. I'll let you know how it turns out later. Last edited by Ruberto; 02-03-2007 at 07:29 PM. Reason: added link |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
|
|