i have a file which includes php and javascript. here is my javascript:
this function is called here:Code:<script language="JavaScript"> function AddToIngList (form) { var Ingredient = form.ingredienttoadd.value; form.ingredients_added.value += Ingredient + "\n"; var objHTML, objText, objinput; objHTML = document.createElement('P'); objHTML.setAttribute('NAME', 'txtTest'); objHTML.setAttribute('ID', 'txtTest'); var strTest = form.ingredienttoadd.value; objText = document.createTextNode(strTest); objinput = document.createElement ('INPUT'); objinput.name = "input" objinput.value = ""; document.body.appendChild(objHTML); objHTML.appendChild(objText); objHTML.appendChild(objinput); } </script>
which is a submit button (generated by php for reasons i wont go into here)PHP Code:echo"<input type=\"button\" name=\"button\" Value=\"add\" onClick=\"AddToIngList(this.form)\">";
so basically everytime someone clicks "button" a new input box is created with the name "input". obviously i want each box to have a unique name which is where my problem lies. is there a way that i can call the newly created input box "input1" and then on the next click, since input1 already exists call it "input2"?
etc...
can anyone help?
thanks





Bookmarks