我有以下html代码,为此我想要PHP代码,它取值选中的复选框。
<div class="right_info">
<div class="tabs_btn">
<ul>
<li><a class="btn" href="">bio</a>
</li>
<li><a class="btn" href="">images</a>
</li>
<li><a class="btn" href="">map</a>
</li>
</ul>
</div>
<div class="clear"></div>
<div id="banner-fade">
<!-- start Basic Jquery Slider -->
<ul class="bjqs">
<li>
<ul>
<li>
<img src="images/img1.jpg" alt="">
<input type="checkbox" name="imagename[]" value="1"><span>selected</span>
</li>
<li>
<img src="images/img1.jpg" alt="">
<input type="checkbox" name="imagename[]" value="2"><span>selected</span>
</li>
<li>
<img src="images/img1.jpg" alt="">
<input type="checkbox" name="imagename[]" value="3"><span>selected</span>
</li>
<li>
<img src="images/img1.jpg" alt="">
<input type="checkbox" name="imagename[]" value="4"><span>selected</span>
</li>
<li>
<img src="images/img1.jpg" alt="">
<input type="checkbox" name="imagename[]" value="5"><span>selected</span>
</li>
<li>
<img src="images/img1.jpg" alt="">
<input type="checkbox" name="imagename[]" value="6"><span>selected</span>
</li>
<li>
<img src="images/img1.jpg" alt="">
<input type="checkbox" name="imagename[]" value="7"><span>selected</span>
</li>
<li>
<img src="images/img1.jpg" alt="">
<input type="checkbox" name="imagename[]" value="8"><span>selected</span>
</li>
<li>
<img src="images/img1.jpg" alt="">
<input type="checkbox" name="imagename[]" value="9"><span>selected</span>
</li>
<li>
<img src="images/img1.jpg" alt="">
<input type="checkbox" name="imagename[]" value="10"><span>selected</span>
</li>
<li>
<img src="images/img1.jpg" alt="">
<input type="checkbox" name="imagename[]" value="11"><span>selected</span>
</li>
<li>
<img src="images/img1.jpg" alt="">
<input type="checkbox" name="imagename[]" value="12"><span>selected</span>
</li>
<li>
<img src="images/img1.jpg" alt="">
<input type="checkbox" name="imagename[]" value="13"><span>selected</span>
</li>
</ul>
</li>
<li>
<ul>
<li>
<img src="images/img1.jpg" alt="">
<input type="checkbox" name="imagename[]" value="14"><span>selected</span>
</li>
<li>
<img src="images/img1.jpg" alt="">
<input type="checkbox" name="imagename[]" value="15"><span>selected</span>
</li>
<li>
<img src="images/img1.jpg" alt="">
<input type="checkbox" name="imagename[]" value="16"><span>selected</span>
</li>
<li>
<img src="images/img1.jpg" alt="">
<input type="checkbox" name="imagename[]" value="17"><span>selected</span>
</li>
<li>
<img src="images/img1.jpg" alt="">
<input type="checkbox" name="imagename[]" value="18"><span>selected</span>
</li>
<li>
<img src="images/img1.jpg" alt="">
<input type="checkbox" name="imagename[]" value="19"><span>selected</span>
</li>
<li>
<img src="images/img1.jpg" alt="">
<input type="checkbox" name="imagename[]" value="20"><span>selected</span>
</li>
<li>
<img src="images/img1.jpg" alt="">
<input type="checkbox" name="imagename[]" value="21"><span>selected</span>
</li>
<li>
<img src="images/img1.jpg" alt="">
<input type="checkbox" name="imagename[]" value="22"><span>selected</span>
</li>
<li>
<img src="images/img1.jpg" alt="">
<input type="checkbox" name="imagename[]" value="23"><span>selected</span>
</li>
<li>
<img src="images/img1.jpg" alt="">
<input type="checkbox" name="imagename[]" value="24"><span>selected</span>
</li>
<li>
<img src="images/img1.jpg" alt="">
<input type="checkbox" name="imagename[]" value="25"><span>selected</span>
</li>
<li>
<img src="images/img1.jpg" alt="">
<input type="checkbox" name="imagename[]" value="26"><span>selected</span>
</li>
</ul>
</li>
</ul>
<!-- end Basic jQuery Slider -->
</div>
<?php $doc=n ew DOMDocument(); $doc->loadHTML('
<ul class="bjqs">'); $liList = $doc->getElementsByTagName('input'); $liValues = array(); foreach ($liList as $li) { $liValues[] = $li->nodeValue; } var_dump($liValues); ?>
</div>
请帮帮我。我使用上面的PHP代码,但它没有选择值。表单的按钮使用jquery。
答案 0 :(得分:0)
foreach ($_POST['imagename'] as $imageval) {
echo "Image #$imageval is selected.<br>";
}
答案 1 :(得分:0)
将所有复选框放在form
标记中
像
<form method="POST" action="your-action-page.php">
your checkbox tags here...
</form>
现在在您的操作页面中..
if(isset($_POST['imagename']))
{
print_r($_POST['imagename'])
}