实际上,标签的一次更改需要更改并显示实际记录例如(如果更改人意味着男人记录将打开(显示))我需要传递选项值内的变量如何传递。
下面是我的html代码:
<select name="category" id ='category' onchange='gender(this)' style="background:transparent">
<option id ='gender' hidden="hidden">Gender</option>
<?php foreach($mens as $row){?>
<option value="men">Boy's</option>
<option value="girl">Girl's</option>
<?php }?>
</select>
这里是我的jquery代码:
<script type="text/javascript">
$(function () {
$("#category").change(function () {
var selectedText = $(this).find("option:selected").text();
var selectedValue = $(this).val();
$( "#list" ).submit();
alert("Selected Text: " + selectedText + " Value: " + selectedValue);
});
});
</script>
下面是我的php代码:
$men ="SELECT * FROM `tbl_master_property` where status=0";
$men_result=$conn->query($men);
$men_projects = array();
while($row=mysqli_fetch_assoc($men_result)){
$men_projects[] = $row;
}
$mens = $men_projects;
echo '<pre>'; print_r($mens);die;
我打印我的$mens它是显示:
Array
(
[0] => Array
(
[pg_id] => 1
[name] => Sri Manikanta New Luxury Paying Guest For Men
[gender] => 0
[location_id] => 0
)
[1] => Array
(
[pg_id] => 2
[name] => Srivari New Executive Paying Guest For Men
[gender] => 0
[location_id] => 0
)
[2] => Array
(
[pg_id] => 3
[name] => Temple View New Executive Pg For Ladies
[gender] => 1
[location_id] => 0
)
[3] => Array
(
[pg_id] => 4
[name] => Srinivasa Luxury Guest For Men
[gender] => 1
[location_id] => 0
)
1条答案
按热度按时间y53ybaqx1#
我认为您正在尝试从
$mens
数组:如果这不是你的意思,你可能要澄清更多。
编辑1:
如果要从中绘制的项目列表很大,则需要使用ajax,但是如果示例相对较小,则可以使用数组进行绘制。
demo:httpshttp://jsfiddle.net/z50m5hnz/:
编辑2:
这是我最后一次猜测你想要什么,从评论我想也许你想重新加载页面,但发送值选择: