View Full Version : Form elements repeated with (javascript) innerHTML is not being posted.

02-26-2007, 05:00 AM
The elements that are repeated with innerHTML of javascript are not being posted in PHP.

function CreateForm(fm){
var str = "";
var str_1 = "";
str = "<select name=\"cmbDays[]\" id=\"cmbDay[]\"><option value=\"1\" selected=\"selected\">Sunday</option><option value=\"2\">Monday</option>";
str += "<option value=\"3\">Tuesday</option><option value=\"4\">Wednesday</option><option value=\"5\">Thursday</option><option value=\"6\">Friday</option>";
str += "<option value=\"7\">Saturday</option></select>";
str += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Hour : <input name=\"housrs[]\" type=\"text\" id=\"housr[]\" value=\"00\" size=\"4\" /> ";
str += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Minute : <input name=\"minutess[]\" type=\"text\" id=\"minutes[]\" value=\"00\" size=\"4\" />";

if(fm.prg_times.value != "" && fm.prg_times.value != 0){
for(i = 0; i < fm.prg_times.value; i++){
str_1 += "<br>" + str;
str_1 = str;
document.getElementById('ScheduleForm').innerHTML = str_1;

But the minutess[] and hours[] are not being posted. Does anyone have idea about it? Neither i can see these form elements in view source too.

That means i want to create some extra form text boxes dynamically with some events.

Can anyone find the solution please?

With Regards
Raju Gautam

02-26-2007, 07:34 AM
With forms, you generally need to use the DOM to create, set the attributes of, and append elements. The trouble with innerHTML with forms is that it tends to wipe things out and/or not increase the form's elements collection properly.

Sometimes innerHTML may be used though. If this is one of those times then your code may simply have some errors in it. It would be much easier to tell and/or to provide substitute DOM code if we could see the markup that your script is to be used with.