Javascript Printing HTML but contents not being captured in form
I'm using this line of JS:
document.getElementById('nameDiv').innerHTML =
'<input type=\"text\" id=\"name\"/>';
to place a textbox in a d开发者_StackOverflow社区iv called 'nameDiv'. When I hit submit on the form it doesn't seem to pick up the contents of this JS generated text box.
Any ideas?
You must supply a name
attribute to have it sent via the POST/GET (without JavaScripting around it, anyway).
document.getElementById('nameDiv').innerHTML =
'<input type=\"text\" id=\"name\" name=\"some-name\"/>';
I used some-name
for example here, you can use the most relevant name
.
Also, why are you escaping "
when your string delimiter is '
and there will be no clash? I assume this is in a string somewhere.
精彩评论