html,通过document.write动态插入表单
我正在尝试使用 document.write 动态插入表单,但由于某些原因该表单不再工作。 这是调用 javascript http://pastebin.com/iMQ3FxHM 的代码,这是编写的 javascript形式 http://pastebin.com/vMn9BrKQ 。 我使用pastebin,因为stackoverflow不会转义html标签,而且我没有任何1010按钮或其他什么
<script type="text/javascript">
document.write('<scr' + 'ipt type="text\/jav' + 'ascript" s' + 'rc="http:\/\/www.a' + 'utotraderuae.net\/mem' + 'bers.j' + 's"><\/sc' + 'ript>');
</script>
<script type="text/javascript">
document.write("<h1>");
document.write(" If you are interested to buy it or if you have any question please contact me through the ");
document.write("");
document.write("form bellow .<\/h1>");
document.write("<p>");
document.write(" <a name=\"contactustop\"><\/a><\/p>");
document.write("<form action=\"http:\/\/autotraderuae.net\/members\/process.php\" id=\"contactus\" method=\"POST\">");
document.write(" <strong><span style=\"font-size: 14px;\"><span style=\"font-family: ");
document.write("");
document.write("arial,helvetica,sans-serif;\"><label for=\"email\">Email *<\/label><\/span><\/span><\/strong><br \/>");
document.write(" <input class=\"textfield\" id=\"email\" name=\"fields[Email]\" style=\"width: 400px;\" type=\"text\" ");
document.write("");
document.write("\/> <\/form>");
document.write("<div class=\"fieldblock\" id=\"fieldblock-comments\">");
document.write(" <span style=\"font-family: arial,helvetica,sans-serif;\"><strong><span style=\"font-size: ");
document.write("");
document.write("14px;\"><label for=\"comments\">Your question<\/label><\/span><\/strong><\/span><br \/>");
document.write(" <textarea class=\"textfield\" cols=\"20\" id=\"comments\" name=\"fields[Comments]\" rows=\"4\" ");
document.write("");
document.write("style=\"width: 400px;\"><\/textarea><\/div>");
document.write("<p>");
document.write(" <button type=\"submit\">Submit<\/button><\/p>");
</script>
I'm trying to insert a form dynamically using document.write but for some reasons the form is not working anymore.
Here is the code which calls the javascript http://pastebin.com/iMQ3FxHM and here is the javascript which writes the form http://pastebin.com/vMn9BrKQ . I'm using pastebin because stackoverflow doesn't escape the html tags and I don't have any 1010 button or whatever is that
<script type="text/javascript">
document.write('<scr' + 'ipt type="text\/jav' + 'ascript" s' + 'rc="http:\/\/www.a' + 'utotraderuae.net\/mem' + 'bers.j' + 's"><\/sc' + 'ript>');
</script>
<script type="text/javascript">
document.write("<h1>");
document.write(" If you are interested to buy it or if you have any question please contact me through the ");
document.write("");
document.write("form bellow .<\/h1>");
document.write("<p>");
document.write(" <a name=\"contactustop\"><\/a><\/p>");
document.write("<form action=\"http:\/\/autotraderuae.net\/members\/process.php\" id=\"contactus\" method=\"POST\">");
document.write(" <strong><span style=\"font-size: 14px;\"><span style=\"font-family: ");
document.write("");
document.write("arial,helvetica,sans-serif;\"><label for=\"email\">Email *<\/label><\/span><\/span><\/strong><br \/>");
document.write(" <input class=\"textfield\" id=\"email\" name=\"fields[Email]\" style=\"width: 400px;\" type=\"text\" ");
document.write("");
document.write("\/> <\/form>");
document.write("<div class=\"fieldblock\" id=\"fieldblock-comments\">");
document.write(" <span style=\"font-family: arial,helvetica,sans-serif;\"><strong><span style=\"font-size: ");
document.write("");
document.write("14px;\"><label for=\"comments\">Your question<\/label><\/span><\/strong><\/span><br \/>");
document.write(" <textarea class=\"textfield\" cols=\"20\" id=\"comments\" name=\"fields[Comments]\" rows=\"4\" ");
document.write("");
document.write("style=\"width: 400px;\"><\/textarea><\/div>");
document.write("<p>");
document.write(" <button type=\"submit\">Submit<\/button><\/p>");
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我看不到表单的结束标签。
另外,“below”应该是“below”
I can't see a closing tag for the form.
Also, 'bellow' should be 'below'
表单在第一个输入字段后关闭
The form is closed after first input field
编写表单的方式非常奇怪 - 不必要的跨度和字体内容。
使用+或\连接并一次性写出表格。无需使用空格格式化表单,因为 html 会忽略它们
Very strange way of writing a form - unnecessary spans and font stuff going on.
Concatenate using + or \ and write the form in one go. No need to fomat the form with spaces since html ignores them