简体   繁体   中英

Dynamically Created Form Elements not submitting with form

I have added some input type elemets in form using javascript.On submitting the form, these elements are not showing

var pos=document.getElementById(rid).rowIndex;
var new_row=document.getElementById("table1").insertRow(1+pos); 
new_row.id="newRow"+rowCount;
    var td5=new_row.insertCell(4);
    td5.align="left";
    td5.innerHTML="<textarea id=\"emailID\" name=\"emailID\" cols=\"40\" rows=\"5\" class=\"textbox\"></textarea>";

I also checked with

    var emailText=document.createElement("textarea");
    emailText.id='emailID';
    emailText.name='emailID',
    emailText.cols=40;
    emailText.rows=5;
    emailText.className="textbox";
    td5.appendChild(emailText);

On submit i checked

alert(document.formName.emailID);

But this is showing undefined. Can any tell where i am wrong?

像这样尝试:

document.forms[0].elements["emailID"];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM