www.webdeveloper.com
Results 1 to 2 of 2

Thread: Problem with dynamically created fields

Hybrid View

  1. #1
    Join Date
    Nov 2012
    Posts
    1

    Problem with dynamically created fields

    Hi I have created few same named combo boxes and text fields on the page. Fields are part of table rows.
    But when I submit the form, I can see all the fields in my java code.

    here is my function which create the fields.


    Code:
            function addRow(tableID) {
            	var oForm = document.forms[0] ; 
            	//alert(oForm.id) ;
    			var ctypes = oForm.elements["claimTypeValues"].value;
    			var tokens = ctypes.split(",") ;
    //			alert("tokens="+tokens) ;
    //			alert("tokens[0]="+tokens[0]) ;
    			
    			var table = document.getElementById(tableID);
    			//alert(table) ;
    
                var rowCount = table.rows.length;
                var row = table.insertRow(rowCount);
                row.setAttribute("id",rowCount) ;
                //alert(rowCount) ;
    
                var cell0 = row.insertCell(0);
                //alert(cell0) ;
    
                var spanTag = document.createElement("span");
    			spanTag.id = "span1";
    			spanTag.className ="dynamicSpan";
    			spanTag.innerHTML = "${content.TableClaimTypeLabel}:";
    			cell0.appendChild(spanTag);
    			
                var _select = createCombo(tokens) ;
                cell0.appendChild(_select);
                oForm.appendChild(cell0) ; 
    
    
    
    here is my html code: 
    
                <form method="post" id="sampleForm" method="POST">
    		               	<select name="claimType" id="claimType">
    ...
    ...
    Please let me know whats wrong in this. This is adding new rows with all values in it, but on submission of form its not giving me all the fields

    -Thanks.

  2. #2
    Join Date
    Mar 2007
    Location
    U.K.
    Posts
    1,127
    This is not your problem
    Code:
                row.setAttribute("id",rowCount) ;
    but an ID must not begin with a digit or consist solely of digits.

    Presumably the createCombo function generates all your added form elements. You need to show it.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles