Append more that one control to div

Posted by Kemrop on Stack Overflow See other posts from Stack Overflow or by Kemrop
Published on 2010-05-14T03:42:05Z Indexed on 2010/05/14 3:54 UTC
Read the original article Hit count: 148

Filed under:

Ok this will be quick. I am collecting data in div by inserting hidden input boxes before i eventually submit to the server. here is Javascript code.

function appendToDiv() { var mydiv=document.getElementById("somediv");

var mydata=document.getElementsByName("description")[0].value;

var myurl=document.getElementsByName("url")[0].value;

var data=mydata+myurl;

mydiv.innerHTML="<input type='hidden' name='sUrl[]'value='"+data+"'/>"

}

I have an onchange event that keeps calling the above guy until i am satisfied that i have all i need to send to the server.Problem is only one input get appended to the div.What could i be missing.

© Stack Overflow or respective owner

Related posts about JavaScript