新手问题!JavaScripts传送checkbox数组到PHP action读取满足checkbox选值的条件来显示MySql列表
问题:thinkphp框架,现在要将下拉列表改成checkbox,通过javascripts读取checkbox数组,然后将数组传到phpaction页面,针对数组的值在...
问题:thinkphp框架,现在要将下拉列表改成checkbox,通过javascripts读取checkbox数组,然后将数组传到php action页面,针对数组的值在页面显示符合条件的数据列表。
原来的代码----------------
html页面:
<div class="Toolbar_inbox">
<php>$st = C('FEEDBACK_STATUS');</php>
<select name="fb_status" id="fb_status" onchange="suerSearchFeedback();">
<volist name="st" k="key" id="st_vo">
<option value="{$key}" <php>if($status == $key){echo "selected";}</php>>{$st_vo}</option>
</volist>
</select>
</div>
function suerSearchFeedback(){
var st = $("#fb_status").val();
var fb_url= U('{$admin_app}/Content/feedback' , ['status',st]);
location.href = fb_url;
}
</script>
php action页面代码:
public function feedback(){
$map['fb_status'] = $_GET['status']?$_GET['status']:'0';
$feedDao = D("Feedback");
$rs = $feedDao->getFeedbacks($map);
if($rs)
$rs['status'] = $map['fb_status'];
$sum = $feedDao ->where("fb_status = {$map['fb_status']}")->count();
$this->assign('feedbacks', $rs);
$this->assign('status', $map['fb_status']);
$this->assign('sum', $sum);
$this->display();
}
-----------------------------------------------------------------------
我自己改的html页面checkbox代码:
<form name="check">
<volist name="st" k="key" id="st_vo">
<input type="checkbox" name="fb_status" id="fb_status" value ="{$key}" <php>if($status == $key){echo "checked";}</php>>{$st_vo}
</volist>
<input type="submit" id="btn_submit" onclick="suerSearchFeedback()" value="提交">
</form>
js代码:
function suerSearchFeedback(){
var st = $("#fb_status").attr("value");
var fb_url= U('{$admin_app}/Content/feedback' , ['status',st]);
location.href = fb_url;
}
}
</script>
请高手指教! 帮助修改js代码和php action页面代码!!! 展开
原来的代码----------------
html页面:
<div class="Toolbar_inbox">
<php>$st = C('FEEDBACK_STATUS');</php>
<select name="fb_status" id="fb_status" onchange="suerSearchFeedback();">
<volist name="st" k="key" id="st_vo">
<option value="{$key}" <php>if($status == $key){echo "selected";}</php>>{$st_vo}</option>
</volist>
</select>
</div>
function suerSearchFeedback(){
var st = $("#fb_status").val();
var fb_url= U('{$admin_app}/Content/feedback' , ['status',st]);
location.href = fb_url;
}
</script>
php action页面代码:
public function feedback(){
$map['fb_status'] = $_GET['status']?$_GET['status']:'0';
$feedDao = D("Feedback");
$rs = $feedDao->getFeedbacks($map);
if($rs)
$rs['status'] = $map['fb_status'];
$sum = $feedDao ->where("fb_status = {$map['fb_status']}")->count();
$this->assign('feedbacks', $rs);
$this->assign('status', $map['fb_status']);
$this->assign('sum', $sum);
$this->display();
}
-----------------------------------------------------------------------
我自己改的html页面checkbox代码:
<form name="check">
<volist name="st" k="key" id="st_vo">
<input type="checkbox" name="fb_status" id="fb_status" value ="{$key}" <php>if($status == $key){echo "checked";}</php>>{$st_vo}
</volist>
<input type="submit" id="btn_submit" onclick="suerSearchFeedback()" value="提交">
</form>
js代码:
function suerSearchFeedback(){
var st = $("#fb_status").attr("value");
var fb_url= U('{$admin_app}/Content/feedback' , ['status',st]);
location.href = fb_url;
}
}
</script>
请高手指教! 帮助修改js代码和php action页面代码!!! 展开
4个回答
展开全部
可以用jquery中的.post方法。.post(
url,{"name","value"},function(data){
//do
}
)//url 是你要提交到的php文件
url,{"name","value"},function(data){
//do
}
)//url 是你要提交到的php文件
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Action里面:
private PromotionManageTo promotionManageTo;
private List<PromotionManageTo> productClass;
get…
set…
SqlMaps里面:
<select resultClass="promotionManage.PromotionManageTo">
……
</select>
JSP里面:
<s:iterator value="productClass" status="productClassLength">
<td>
<input type="checkbox" name="promotionManageTo.productId" value="<fs:property value="productId"/>" <c:if test="${fn:containsIgnoreCase(promotionManageTo.productId, productId)}">checked="checked"</c:if> />
</td>
</s:iterator>
private PromotionManageTo promotionManageTo;
private List<PromotionManageTo> productClass;
get…
set…
SqlMaps里面:
<select resultClass="promotionManage.PromotionManageTo">
……
</select>
JSP里面:
<s:iterator value="productClass" status="productClassLength">
<td>
<input type="checkbox" name="promotionManageTo.productId" value="<fs:property value="productId"/>" <c:if test="${fn:containsIgnoreCase(promotionManageTo.productId, productId)}">checked="checked"</c:if> />
</td>
</s:iterator>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
听不懂
追问
简单的说就是用javascript读取checkbox的数组,然后传值到php页面,针对数组进行操作
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询