简体   繁体   English

JQuery和HTML:如何使用echo $ _POST将数据从一个表单获取到另一个表单

[英]JQuery & HTML: How to use echo $_POST to get data from one form to another

im creating an application using JQuery and HTML. 我正在使用JQuery和HTML创建一个应用程序。 In the first form i you are asked to enter a id, then once this is checked you are asked to add in more information. 在第一种形式中,我们要求您输入一个ID,然后在选中此项后,系统会要求您添加更多信息。 The problem that i am having is that after you press submit in the second page i want to save all the information together, this includes the id entered in the first page. 我遇到的问题是,在第二页中按提交后,我想将所有信息保存在一起,这包括在第一页中输入的ID。

I forms are created using HTML and the functionality is done using JQuery. 我的表单是使用HTML创建的,功能是使用JQuery完成的。 I am trying to use the following code but it is not working 我试图使用以下代码,但它无法正常工作

var id = echo $_POST['cardNumber'];

I am using this in one of the .js pages. 我在其中一个.js页面中使用它。 Here is the HTML from the first page that is asking for the ID 这是第一页要求提供ID的HTML

<form id="RegisterForm" method="post" data-ajax="false" id="registerCardForm" action="register.html"> 
        <input type="text" id="cardNumberRegField" type="tel"  name="cardNumber" class="required number register" minlength="16" maxlength="16"/> 
        <input name="Submit" type="submit" class="button" value="Register"/>
</form>

Can anyone tell me what is going wrong here? 谁能告诉我这里出了什么问题?

如果你想在js变量中存储php值你应该这样做,没有引号js变量设置为undefined

var id = "<?php echo $_POST['cardNumber']; ?>"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM