...

View Full Version : Form Input Arrays



cesarcesar
07-12-2007, 07:16 PM
Im using this Calendar, http://www.calendarxp.net/, on my page. It works great as exampled on the site. My problem comes in when i use the calendar in a form textfield that is an array. I think my *document.this_form.example[]* call is incorrect, but my novice JS knowledge is preventing me from getting it right.

Please explain how i can get the calendar to work in the following example. The first textfield call works since it is not in an array.

Thanks much.



<form method="POST" action="example.php" name="this_form">
<input type="text" id="example_working" name="example_working" onfocus="if(self.gfPop)gfPop.fPopCalendar(document.this_form.example_working);return false;">
<input type="text" id="example[]" name="example[]" onfocus="if(self.gfPop)gfPop.fPopCalendar(document.this_form.example[]);return false;">
<input type="text" id="example[]" name="example[]" onfocus="if(self.gfPop)gfPop.fPopCalendar(document.this_form.example[]);return false;">
<input type="text" id="example[]" name="example[]" onfocus="if(self.gfPop)gfPop.fPopCalendar(document.this_form.example[]);return false;">
<input type="text" id="example[]" name="example[]" onfocus="if(self.gfPop)gfPop.fPopCalendar(document.this_form.example[]);return false;">
<input type="text" id="example[]" name="example[]" onfocus="if(self.gfPop)gfPop.fPopCalendar(document.this_form.example[]);return false;">
</form>

glenngv
07-12-2007, 07:23 PM
Just the this keyword to refer to itself.

<input type="text" id="example[]" name="example[]" onfocus="if(self.gfPop)gfPop.fPopCalendar(this);return false;">

But in general, to access elements with special symbols in names, you need to use square bracket notation.

document.this_form.elements["example[]"]
See my sig for more info on this technique.

cesarcesar
07-12-2007, 07:48 PM
thanks. this is perfect. i used the first *this* example.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum