0

Hi,

I have a js script:

var inputCounter = 0;
function addInput(divName){	 
	var newdiv = document.createElement('div');	
	newdiv.innerHTML = "somefield1: " + "<input type='text' style='width: 250px;' name='f1[]'> somefield2: " + "<input type='text' style='width: 200px;' name='f2[]'>";
	document.getElementById(divName).appendChild(newdiv);
	inputCounter++;	

}

and the data was received by the php script

$_SESSION["f1"] = $_POST["f1"];	
$_SESSION["f2"] = $_POST["f2"];

was working perfectly, until i did some minor changes to the script that was not even related to that part of the script, and it now shows Notice: Undefined index: f1 in C:\Apache2.2\htdocs\ts\index.php on line xxx
meaning that the data is not set anymore. everything else is working perfectly. the fields are still added as before, but the data does not post. what might cause this not to work all of a sudden?

Edited by Buppy: n/a

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by aristos32
0

edit: just tested the page on IE and there it still works as it should. Firefox, however, gives me that error. even on different computers. now i'm confused.

0

Ok, i've found that i need to .createElement('input'); for each of them.

How do i do it nicely so i have a div with several different inputs like i'm having now in the innerHTML part?

And why was it working before and still is on IE?

0

hi. I have the same problem. But on Chrome and FF.
dynamically created elements don't get a 'name', so they are not submitted on the form $_POST.

How did you work around this issue?

thanks

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.