使用javascript实现一个表单两个操作
尝试首先使用一个js按钮填充字段,然后使用第二个js按钮提交收集数据的字段 当我单击“填充”按钮时,我可以得到要填充的字段,但当我尝试提交时,ordertest.php上没有显示任何值 谢谢使用javascript实现一个表单两个操作,javascript,php,forms,action,Javascript,Php,Forms,Action,尝试首先使用一个js按钮填充字段,然后使用第二个js按钮提交收集数据的字段 当我单击“填充”按钮时,我可以得到要填充的字段,但当我尝试提交时,ordertest.php上没有显示任何值 谢谢 <form action="#" name="data" id="data"> <input type='button' value='Populate' onclick='popContact()' /><BR> <input type="submit" oncl
<form action="#" name="data" id="data">
<input type='button' value='Populate' onclick='popContact()' /><BR>
<input type="submit" onclick="document.getElementById('data').action = 'ordertest.php'" value="Payment Submit" /><BR>
Contact Info:<BR>
First Name: <input type='text' readonly="readonly" name='cfname' /><BR>
Last Name: <input type='text' readonly="readonly" name='clname' /><BR>
Email:<input type='text' readonly="readonly" name='cemail' /><BR>
</form>
<script type="text/javascript">
function popContact()
{
var c = window.external.Contact;
data.cfname.value = c.FirstName;
data.clname.value = c.LastName;
data.cemail.value = c.EmailAddr;
}
</script>
---> ordertest.php
<?php
$current_firstname = $_POST["cfname"];
$current_lastname = $_POST["clname"];
$current_email_address = $_POST["cemail"];
echo "current_firstname ".$current_firstname;
echo "<br>";
echo "current_lastname ".$current_lastname;
echo "<br>";
echo "current_email_address ".$current_email_address;
?>
联系信息:
名字:
姓氏:
电子邮件:
函数popContact()
{
var c=window.external.Contact;
data.cfname.value=c.FirstName;
data.clname.value=c.LastName;
data.cemail.value=c.EmailAddr;
}
--->ordertest.php
也试过
<input type="submit" onclick="this.form.action='ordertest.php'" value="Payment Submit" />
Oppps
使用此组合有效,$\u获得
<input type="submit" onclick="this.form.action='order.php'" method="POST" value="Payment Submit" />
---> ordertest.php
<?php
$current_firstname = $_GET["cfname"];
$current_lastname = $_GET["clname"];
$current_email_address = $_GET["cemail"];
echo "current_firstname ".$current_firstname;
echo "<br>";
echo "current_lastname ".$current_lastname;
echo "<br>";
echo "current_email_address ".$current_email_address;
?>
--->ordertest.php
Oppps
使用此组合有效,$\u获得
<input type="submit" onclick="this.form.action='order.php'" method="POST" value="Payment Submit" />
---> ordertest.php
<?php
$current_firstname = $_GET["cfname"];
$current_lastname = $_GET["clname"];
$current_email_address = $_GET["cemail"];
echo "current_firstname ".$current_firstname;
echo "<br>";
echo "current_lastname ".$current_lastname;
echo "<br>";
echo "current_email_address ".$current_email_address;
?>
--->ordertest.php
是否必须使用JS设置action属性?当您执行
时,它是否工作?使用popContact功能是否必须使用JS设置action属性?当您执行
时,它是否工作?使用popContact功能是否必须使用JS设置action属性?当您执行
操作时,它是否工作?使用会中断popContact功能