[英]how can i get sum of checkbox value and textbox value in another textbox when checkbox is checked or if checkbox unchecked remove the value
[英]How can i show value when checkbox was checked using loop for?
當使用loop選中復選框時,如何顯示值?
................................................... ................................................... ................................................... ......
<form method="post">
<input type="checkbox" name="a_0" value="0">0
<input type="checkbox" name="a_1" value="1">1
<input type="checkbox" name="a_2" value="2">2
<input type="checkbox" name="a_3" value="3">3
<input type="checkbox" name="a_4" value="4">4
<input type="submit" name="submit">
</form>
<?php
if(isset($_POST["submit"]))
{
for($i=0;$i<4;$i++)
{
if(${"_POST[a_{$i}]"} != '')
{ echo ${"_POST[a_{$i}]"}; }
else
{ echo "no"; }
}
}
?>
嘗試這樣:
<?php
if(isset($_POST["submit"]))
{
for($i=0;$i<4;$i++)
{
if(${"_POST[a_{$i}]"} != '')
{ echo $_POST['a_{$i}']; }
else
{ echo "no"; }
}
}
?>
更改:
${"_POST[a_{$i}]"}
至:
$_POST['a_' . $i]
或(請注意雙引號):
$_POST["a_$i"]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.