将javascript innerhtml中的数据传递到数据库



document.getElementById("message"(.innerHTML='choice 1:type="text"name="choice"value=">

有人知道如何将name="choice"传递到数据库吗?

我有一个未定义的索引选择错误。

您在那里提出了一个巨大的问题,但为了提供帮助,工作流程可能是:

1. post your data using ajax to a serverside handler
2. process and validate/sanitise the data and pass it to the database
3. once done return a confirmation (or error) message back tot he frontend
4. handle the ajax response and feedback to the user

这里有一些关于ajax的信息,这里有关于pdo和mysql数据库函数的php手册文档,这里有jquery的文档,这可能会使ajax过程成为一个更容易的

仔细阅读资源,尝试实现您需要的功能,如果您在编写的代码中遇到了较小的、可重复的问题,

您必须在innreHTML中创建表单。对于ex,在您的JavaScript中,

var display="<form action='url' method='post'>"+
 "<input type='text' name='Name'/>"+
 "<input type='submit' name='Submit'/>"+
 "</form>";

然后,您可以使用JSTL标记将这个文本框值添加到另一个JSP页面代码的数据库中。

最新更新