CalendarXP.net Support Forum Index CalendarXP.net Support
Most forums here are private and invisible to public.
 
 FAQFAQ   SearchSearch   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to access a form field whose name has brackets or dots in it?

 
Post new topic   Reply to topic    CalendarXP.net Support Forum Index -> CalendarXP F.A.Q.
View previous topic :: View next topic  
Author Message
calendarxp
Site Admin


Joined: 30 Jan 2005
Posts: 409

PostPosted: Tue Nov 14, 2006 3:33 pm    Post subject: How to access a form field whose name has brackets or dots in it? Reply with quote

Although this has nothing to with calendarxp, we'd love share a tip with our users.

Some web framework requires the field name to contain brackets, e.g. param['abc'], or dots, e.g. obj.txt. In order to access those fields in javascript, you cannot use the normal way like form1.field1 directly, because it will look like form1.obj.txt and will confuse the javascript engine as it interprets as getting the txt attribute of field obj in form1, instead of field "obj.txt" in form1.

The solution is to use the associative array feature of javascript instead, i.e. form1.elements["obj.txt"] or form1.elements["param['abc']"]. This way, the javascript engine will correctly parsing the name and give you the right element(field) of form instead of an object-not-found error.

_________________
Copyright 2003-2011 Idemfactor Solutions, Inc. All rights reserved.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    CalendarXP.net Support Forum Index -> CalendarXP F.A.Q. All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Copyright 2003- Idemfactor Solutions, Inc. All rights reserved.
Powered by phpBB © 2001, 2005 phpBB Group