Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.