Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Apr 2007
    Posts
    144
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Form Input Arrays

    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.

    Code:
    <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>

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,043
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Just the this keyword to refer to itself.
    Code:
    <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.
    Code:
    document.this_form.elements["example[]"]
    See my sig for more info on this technique.

  • #3
    Regular Coder
    Join Date
    Apr 2007
    Posts
    144
    Thanks
    5
    Thanked 0 Times in 0 Posts
    thanks. this is perfect. i used the first *this* example.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •