Results 1 to 2 of 2

Thread: Form elements repeated with (javascript) innerHTML is not being posted.

  1. #1
    Join Date
    Jan 2007
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Form elements repeated with (javascript) innerHTML is not being posted.

    The elements that are repeated with innerHTML of javascript are not being posted in PHP.

    Code:
    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;
    			}
    		}
    		else{
    			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

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •