How can I get the data from an ajax created textfield

Hi,

I have a form, and inside of the form , I have some text fields created
by ajax ( the number of text fields is depended on the user’s choice)
but when I click on my submit button, rails only send me the data where
the components were created normaly. the textfields created by ajax are
never put inside of the “params” object.

Does anyone know how to get thoses text fields???

Thanks you very much

Sayoyo

Do all of the text fields have a unique value for name=“whatever” ? I’ve
had problems with my field names not getting created correctly.
Also, do you really need to use AJAX? You could probably just use
client-side javascript for creating blank text fields.

Here is the javascript I use to insert a pair of text fields. I’m not
sure it’s the best way, but it’s woked well so far. The only requirement
is that you have this:
In your page. This is
good, because it allows me to set the value of counter if I’m editing an
object that already has some of these fields. Then I can start the
generated fields at 12 or 20 or whatever.

Hope this helps!
Jason

Code:

var counter = 0;

function addField()
{
if(counter == 0) {
counter = parseInt(document.getElementById(“counter”).value);
}
//Get the container Element.
var containerDiv = document.getElementById(“fields”);

//Set the name for the new input
var inputIdName = "attribute_" + counter;

//Create the DIV
var newInput = document.createElement("div");

//Name the DIV
newInput.setAttribute("id",inputIdName);

//Put the HTML we want into a variable
var insertHTML = '<table style="margin-left: 30px;" >\n<tr>' +
        '<td>Name: <input type="text" name="attribute[' + counter +

‘]" size=“30” />’ +
'

Value: ’ +
‘’;
//Put the HTML into our div
newInput.innerHTML = insertHTML;
containerDiv.appendChild(newInput);

//Increment the counter
counter = counter + 1;

}