[英]How can i send data to a *.php file from a submitted select form without refreshing
[英]After many Form data are submitted to php file, How can the php file receive that data input?
我的html代碼-在表單結構中,有1個data-role =“ collapsible-set”和許多data-role =“ collapsible”。 有很多復選框,如下面的代碼。
<form action="sx_oriented.php" method="get" id="symptom">
<div data-role="collapsible-set">
<div data-role="collapsible">
<h3>Circulatory and Respiratory systems? Click me!</h3>
<fieldset data-role="fieldcontain">
<label for="symptom">Select your Symptoms</label>
<table>
<tr><th><input type="checkbox" name="r_code[]" value="R00"></th><th> Abnormalities of heart beat</th></tr>
<tr><th><input type="checkbox" name="r_code[]" value="R00.0"></th><th> Tachycardia, unspecified</th></tr>
<tr><th><input type="checkbox" name="r_code[]" value="R00.1"></th><th> Bradycardia, unspecified</th></tr>
<tr><th><input type="checkbox" name="r_code[]" value="R00.2"></th><th> Palpitations</th></tr>
<tr><th><input type="checkbox" name="r_code[]" value="R00.8"></th><th> Other and unspecified abnormalities of heart beat</th></tr>
<tr><th><input type="checkbox" name="r_code[]" value="R01"></th><th> Cardiac murmurs and other cardiac sounds</th></tr>
<tr><th><input type="checkbox" name="r_code[]" value="R01.0"></th><th> Benign and innocent cardiac murmurs</th></tr>
<tr><th><input type="checkbox" name="r_code[]" value="R01.1"></th><th> Cardiac murmur, unspecified</th></tr>
</table>
</div>
<div data-role="collapsible">
<h3>Digestive system and abdomen? Click me!</h3>
<fieldset data-role="fieldcontain">
<label for="r_code[]">Select r_code[]</label>
<table>
<tr><th><input type="checkbox" name="r_code[]" value="R10"></th><th> Abdominal and pelvic pain</th></tr>
<tr><th><input type="checkbox" name="r_code[]" value="R10.0"></th><th> Acute abdomen</th></tr>
<tr><th><input type="checkbox" name="r_code[]" value="R10.1"></th><th> Pain localized to upper abdomen</th></tr>
<tr><th><input type="checkbox" name="r_code[]" value="R10.10"></th><th> Abdomen pain, Right upper quadrant</th></tr>
<tr><th><input type="checkbox" name="r_code[]" value="R10.11"></th><th> Abdomen pain, Left upper quadrant</th></tr>
<tr><th><input type="checkbox" name="r_code[]" value="R10.12"></th><th> Epigastric pain</th></tr>
<tr><th><input type="checkbox" name="r_code[]" value="R10.19"></th><th> Upper abdominal pain, unspecified</th></tr>
<tr><th><input type="checkbox" name="r_code[]" value="R10.2"></th><th> Pelvic and perineal pain</th></tr>
<tr><th><input type="checkbox" name="r_code[]" value="R10.3"></th><th> Pain localized to other parts of lower abdomen</th></tr>
<tr><th><input type="checkbox" name="r_code[]" value="R10.30"></th><th> Abdomen pain, Right lower quadrant</th></tr>
<tr><th><input type="checkbox" name="r_code[]" value="R10.31"></th><th> Abdomen pain, Left lower quadrant</th></tr>
<tr><th><input type="checkbox" name="r_code[]" value="R10.32"></th><th> Periumbilical pain</th></tr>
</table>
</div>
----10 more "collapsible"---
<input type="submit" value="submit">
</form>
然后,執行action =“ sx_directional.php”,如下所示
<?php
$checked = $_GET['r_code'];
for($i=0; $i < count($checked); $i++){
echo "Selected " . $checked[$i] . "<br/>";
}
?>
但是,我沒有結果! 為什么不?? 請幫我!!
首先,我將在表單中使用POST
。 因此,將method="get"
更改為method="POST"
。
然后,您可以執行此操作。
<?php
$checked = $_POST['r_code'];
if(isset($checked)){
foreach($checked as $check){
echo "Selected ".$check."<br />";
}
}
?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.