Jump to content

Archived

This topic is now archived and is closed to further replies.

Chewie71

Reading values from dynamically created text boxes...

Recommended Posts

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...
[code]<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\");'>[/code]

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

[code]x=0;
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
}[/code]

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?

Thanks,
Matt

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.