如何将javascript中的变量传递给PHP
我正在尝试将js变量fq和fd传递给PHP变量 这是我的HTML表单如何将javascript中的变量传递给PHP,javascript,php,html,Javascript,Php,Html,我正在尝试将js变量fq和fd传递给PHP变量 这是我的HTML表单 <form style="width: 60%; margin-top: 1%;" class="w3-modal-content w3-animate-top w3-padding w3-round w3-light-gray" action="trytesting.php" method="POST"> <span onclick="document.getElementById('form').
<form style="width: 60%; margin-top: 1%;" class="w3-modal-content w3-animate-top w3-padding w3-round w3-light-gray" action="trytesting.php" method="POST">
<span onclick="document.getElementById('form').style.display='none'" class="w3-button w3-round w3-hover-red w3-teal w3-display-topright">×</span>
<p>
<label>Title : </label>
<input class="w3-input w3-border w3-border-blue" type="text" name="name"></p>
<label>From : </label>
<input class="w3-input w3-border w3-border-blue" type="text" name="name"></p>
<label>To :</label>
<input class="w3-input w3-border w3-border-blue" type="text" name="company"></p>
<table class="w3-table w3-striped w3-white" id="myTable">
<tr class="w3-teal ">
<th class="w3-padding-16">QTY</th>
<th class="w3-padding-16">DESCRIPTION</th>
<th class="w3-padding-16">Update</th>
</tr>
<tr>
<td>1</td>
<td>FOR INSPECTION</td>
<td>edit</td>
</tr>
</table>
<p>Quantity : <input class="w3-input w3-border w3-border-blue" type="text" name="qty" id="qty1"></p>
<p>Description : <input class="w3-input w3-border w3-border-blue" type="text" name="desc" id="desc1"></p>
<a href="#" class="w3-btn w3-teal w3-round" name="btnaddTT" onClick="addFunction()" style="width: 20%">Add Item</a>
<p>
<label>Training Date:</label>
<input type="date" name="tdate" value="<?php echo Date('Y-m-d'); ?>">
</p>
<p>
<label>Recieved by :</label>
<input class="w3-input w3-border w3-border-blue" type="text" name="recieved"></p>
<button class="w3-btn w3-cyan w3-round" name="btnaddItem" onclick="getData()" style="width: 100%">Add Contact</button>
<a href="#" onclick="getData()">Try</a>
<br />
</form>
&时代;
标题:
发件人:
致:
数量
描述
更新
1.
供检查
编辑
数量:
说明:
培训日期:
将数据作为GET发送,请使用以下代码
if(isset($GET['fq'])){
$output = $GET['fq'];
$output2 = $GET['fd']
echo "this is : $output";
echo "this is : $output2";
}
else
echo "nothing";
将数据作为GET发送,请使用以下代码
if(isset($GET['fq'])){
$output = $GET['fq'];
$output2 = $GET['fd']
echo "this is : $output";
echo "this is : $output2";
}
else
echo "nothing";
试试这个,应该有用-
if(isset($GET['fq'])){
$output = $GET['fq'];
$output2 = $GET['fd']
echo "this is : ".$output;
echo "this is : ".$output2;
}
else
echo "nothing";
试试这个,应该有用-
if(isset($GET['fq'])){
$output = $GET['fq'];
$output2 = $GET['fd']
echo "this is : ".$output;
echo "this is : ".$output2;
}
else
echo "nothing";
我应该是$\u POST
和/或$\u GET
,注意下划线。我应该是$\u POST
和/或$\u GET
,注意下划线。你将html放入url而不编码吗?这是不可以的。你把html放进url而不编码它?那是不可以的。