2011-10-05 64 views
0

我希望有人能帮助我。我对如何实现这一点有点遗憾:我试图将在我的PHP中生成的信息传递给用Javascript制作的另一个表单。
例如,如果我在输入字段中输入了我的名字,然后单击提交,那么它将转到具有实际表单的另一个页面,并且在那里已经填写了名字。将php表单信息传递给javascript表单

我注意到的一件事是javascript表单不在<form>标记内,它在一堆带有一些输入字段的表中。如果这可以帮助理解我的意思,我可以发布它在pastebin中的样子。

此外,这个脚本即时无法编辑它,我没有做到这一点,它是你刚才在你的网站上自动生成的脚本之一。

我的形式如下:

<form action="auto-form/index.php" method="post" name="openleads" onsubmit="return checkForm(this);"> 

<label for="first">First Name <span class="required">*</span></label> 
<input id="first_name" type="text" name="first" applicationforms="true" /><br> 
<label class="error" for="name" id="first_name_error" style="color:#F00; font-size:11px;">This field is required.</label> 

<span class="fields">Zip <span class="required">*</span></span> 
<input id="zip" type="text" name="zip" applicationforms="true" /><br> 
<label class="error" for="name" id="zip_error" style="color:#F00; font-size:11px;">This field is required.</label> 

<label for="last">Last Name <span class="required">*</span></label> 
<input id="last_name" type="text" name="last" applicationforms="true" /><br> 
<label class="error" for="name" id="last_name_error" style="color:#F00; font-size:11px;">This field is required.</label> 

<span class="fields">Email <span class="required">*</span></span> 
<input id="email" type="text" name="email" applicationforms="true" /><br> 
<label class="error" for="name" id="email_error" style="color:#F00; font-size:11px;">This field is required.</label> 
<input class="button" type="submit" name="send" value="Send" /> 

</form> 

任何帮助表示赞赏;就像我说的那样,我对这个如何处理有点不知所措。

+0

,可以用PHP可以更容易地完成。此外,你的表单标记是搞砸了。 '

回答

1

PHP-form.php的

<form action="javascript-form.php" method="post"> 
    <input type="text" name="name" /> 
    <input type="submit" value="Submit" /> 
</form> 

JavaScript的form.php的

<form action="" method=""> 
    <input type="text" name="name" value="<?= (isset($_POST['name'])?htmlentities($_POST['name'],ENT_QUOTES):''); ?>" /> 
    <input type="submit" value="Submit" /> 
</form> 

用PHP输出所张贴的值到表单字段的value属性。您也可以使用GET变量并使用javascript来解析window.location并刮取这些表单值。

+0

即时通讯对不起,我应该提到,在JavaScript形式即时通讯无法编辑它我只是能够把它放在我想要放置的地方 – NukleHead

+0

@NukleHead:“把它放在我想要放置的位置”是什么意思?这是一个iframe,一个脚本生成的表单,...?您可以绑定到原始表单的提交,然后阅读表单值,然后使用JavaScript将它们“转移”到新表单 - 只要这两个表单位于同一个域中即可。 –

+0

更有帮助它看起来像这样,它会生成,它不会完全在iframe中 inputOptions = { 'UserID':'#####', 'Product ':'payday', 'ProductTemplate':'original', 'Server':'https://altohost.com/' }; document.write(' NukleHead

0

这似乎得到这个工作

<script type="text/javascript" src="http://jquery.offput.ca/js/jquery.timers.js"></script> 
<script> 
$(document).everyTime(1000,function(i){ 
    if($('#ui-datepicker-div').length>0) 
    { 
     $('#first_name').val('<?php echo $_POST['first_name']; ?>'); 
     $('#last_name').val('<?php echo $_POST['last']; ?>'); 
     $('#zip').val('<?php echo $_POST['zip']; ?>'); 
     $('#email').val('<?php echo $_POST['email']; ?>'); 
    } 
}) 
$('#first_name').val('test'); 
</script>