mysql - Adding form fields using javascript in a jsp program? -
basically have javascript function allows user add forms he/she wishes. have couple of input fields , have no problem adding them. here code.
<script> var counter = 1; function addinput(divname){ var newdiv = document.createelement('div'); newdiv.innerhtml = "<center><br><hr width='300'>\n\ control number: <br><input type='text' name='control_number'>\n\ date of pull out: <br><br><input type='date' name='pulloutdate'>\n\ \n\item description: <br><br> <select name='des'>\n\ \n\ <% while(rselectrecord.next()){ %> <option value="<%=rselectrecord.getstring("item_code")%>"><%=rselectrecord.getstring("item_code")%></option> <% } %> </center>"; document.getelementbyid(divname).appendchild(newdiv); counter++; } </script>
however in innerhtml, values in item description should taken database have created. thinking of doing way put scriplet inside , values. not work.
is there way add forms selections taken database , place in javascript function? or there way create form in different page , include in newdiv.innerhtml = "filenamehere"? please help? thanks!
what you're doing should work. think scriptlets adding unescaped newlines javascript string, breaking it. so, try this:
\n\ <% while(rselectrecord.next()){ %>\ <option value='<%=rselectrecord.getstring("item_code")%>'><%=rselectrecord.getstring("item_code")%></option>\ <% } %>\ \n</select>\n\ </center>";
Comments
Post a Comment