0

hi,

I have an HTML form setup. It has several input text fields to enter the data. I also want the user to add more text fields dynamically if he wishes to enter more data. If I do it directly though PHP using loops, I loose the data previously entered in the fields.

I was wondering about implementing Ajax to solve this probelm to generate multiple text fields. I am new to using Ajax technique, and I do not have solid JavaScript background, and I am kind of strugling.

Thanks very much! Any help would be greatly appreciated!

3
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by langsor
0

People are throwing around the word AJAX as if it is synonymous with DHTML.

var container = document.getElementById('the_form_container');
var newfield = document.createElement('input');
newfield.type = 'text';
newfield.id = someCounter+'_suffix';
container.appendChild(newfield);

^ Not AJAX

0

You can use DHTML as mentioned above ... no problem. Or if you want to stick to the ol' familiar PHP looping you can do something like this to keep the value of your form field on page reload ...

<input type="text" name="test" value="<? print $_GET['test'] ?>" />

If page reload is what you mean by loops.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.