Jump to content


Reading values from dynamically created text boxes...

  • Please log in to reply
No replies to this topic

#1 Chewie71

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 28 March 2006 - 03:48 PM

I've been implementing some AJAX/Javascript and have been playing around with some dynamic forms. I'm using AJAX so that when a user enters data into a textbox, AJAX validates that data and then creates a new textbox so they can enter more data to be validated. I'm trying to figure out how to get javascript to read back the values from an unknown number of these textboxes. There may be one...there may be five...

The textbox code looks something like this...
<input type=text name='cd0' onblur='populateSections(document.forms[\"adminForm\"], this.value, \"user\");'>
<input type=text name='cd1' onblur='populateSections(document.forms[\"adminForm\"], this.value, \"user\");'>
<input type=text name='cdn' onblur='populateSections(document.forms[\"adminForm\"], this.value, \"user\");'>

I want to be able to read in an 'n' number of values from textboxes named 'cd1' through 'cdn'. Something like this...

while (document.myFormName.cdx)
  readData = document.myFormName.cdx.value;
  //Do some AJAX stuff with the readData (rebuild the textboxes and add a new empty textbox with name="cdx+1"
  x++;  //Go around again and read the next textbox value if there is one

I know this doesn't work, and I can't seem to find anyplace that says how to make this work. Is anyone else doing something like this?


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users