开发者

change innerHTML to form

开发者 https://www.devze.com 2023-04-11 20:08 出处:网络
Today I was trying to make the innerHTML of a DIV change to a FO开发者_运维问答RM, but I keep getting the following error Uncaught SyntaxError: Unexpected token ILLEGAL. I\'ve modified the code to say

Today I was trying to make the innerHTML of a DIV change to a FO开发者_运维问答RM, but I keep getting the following error Uncaught SyntaxError: Unexpected token ILLEGAL. I've modified the code to say changed and it works fine, but if I try to change it to the following code it gives me that error.

document.getElementById(div).innerHTML = '<form method="post" action="all.php?f=mu">
<input name="afterurl" type="hidden" value="<?php $url ?>" />
<input name="preurl" type="hidden" value="" />
<input name="newurl" type="text" value="" />
</form>';

Any idea how I can get it to work?


You can't have text span multiple lines like that in JS. Use string concatenation or put it into one line

document.getElementById(div).innerHTML = '<form method="post" action="all.php?f=mu">' +
'<input name="afterurl" type="hidden" value="<?php $url ?>" />' +
'<input name="preurl" type="hidden" value="" />' +
'<input name="newurl" type="text" value="" />' +
'</form>';
0

精彩评论

暂无评论...
验证码 换一张
取 消