jsp中checkbox用法詳解
String[] picked = request.getParameterValues("open");
if (picked != null) {
for (int i = 0;i < picked.length; i++) {
// System.out.println("11"+picked[i]);
uDao.getCheckOpen( picked[i]);
}
}
今天懷著惶恐的心情用了下checkbox,一直以為挺神秘的東西,可是當(dāng)你決定靜下心來要把它搞定的時(shí)候,才發(fā)現(xiàn)事情遠(yuǎn)沒有想象中困難O(∩_∩)O~
*****************************************************************************************************
從網(wǎng)上找的理論:
(獲取checkbox中的值)
String[] picked = request.getParameterValues("colname");
String[] a=new String[20];
if (picked != null) {
for (int i = 0;i < picked.length; i++) {
out.println(" "+picked[i]);
} else {
out.println ("none");
}
如何jsp頁面checkbox實(shí)現(xiàn)全選.
用javascript吧。
<html>
<body>
<script>
function kk(){
var handleEl = document.getElementById("kkHandler");
var els = document.getElementsByName("kk");
for(i=0;i<els.length;i++){
els[i].checked = handleEl.checked;
}
}
</script>
<input type=checkbox onclick="kk()" name="kkHandler">全選<br>
<input type=checkbox name="kk">
<input type=checkbox name="kk">
</body>
</html>
2:
<form name="form" ID="Form1">
<input type="checkbox" name="id" value="" ID="Checkbox1">1
<input type="checkbox" name="id" value="" ID="Checkbox2">2
<input type="checkbox" name="chose" value="" onclick="selectAll()" ID="Checkbox5">allselect
</form>
<script>
function selectAll()
{
if(!document.form.id.length){
if(document.form.chose.checked){
document.form.id.checked=true;
}
else{
document.form.id.checked=false;
}
}
else{
for(var i=0;i<document.form.id.length;i++){
if(document.form.chose.checked){
document.form.id[i].checked=true;
}
else{
document.form.id[i].checked=false;
}
}
}
}
</script>
******************************************************************************************************
我的代碼
jsp頁面代碼:
<script LANGUAGE = "javaScript">
<!--
function selectAll()
{
if(!document.form.open.length){
if(document.form.chose.checked){
document.form.open.checked=true;
}
else{
document.form.open.checked=false;
}
}
else{
for(var i=0;i<document.form.open.length;i++){
if(document.form.chose.checked){
document.form.open[i].checked=true;
}
else{
document.form.open[i].checked=false;
}
}
}
}
-->
</script>
<logic:present name="Infor">
<logic:iterate id="show" name="Infor">
<tr bgcolor = '#E7F1FE'>
<td width="5%">
<logic:equal value="未開通" name="show" property="status">
<input type="checkbox" name="open" value="<bean:write name="show" property="legalPersonCode" />">
</logic:equal>
action 里面的寫法:
String[] picked = request.getParameterValues("open");
if (picked != null) {
for (int i = 0;i < picked.length; i++) {
// System.out.println("11"+picked[i]);
uDao.getCheckOpen( picked[i]);
}
}
相關(guān)文章
ResourceBundle類在jsp中的國際化實(shí)現(xiàn)方法
下面小編就為大家?guī)硪黄猂esourceBundle類在jsp中的國際化實(shí)現(xiàn)方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-07-07
運(yùn)用JSP+ajax實(shí)現(xiàn)分類查詢功能的實(shí)例代碼
本篇文章主要介紹了運(yùn)用JSP+ajax實(shí)現(xiàn)分類查詢功能的實(shí)例代碼,具有一定的參考價(jià)值,有興趣的可以了解一下2017-07-07
JSP動(dòng)態(tài)實(shí)現(xiàn)web網(wǎng)頁登陸和注冊(cè)功能
這篇文章主要介紹是動(dòng)態(tài)實(shí)現(xiàn)web網(wǎng)頁登陸和注冊(cè)功能的示例代碼,文中代碼講解詳細(xì),對(duì)我們學(xué)習(xí)JSP有一定的幫助,感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2021-12-12
jsp網(wǎng)頁計(jì)數(shù)器實(shí)現(xiàn)示例
網(wǎng)頁計(jì)數(shù)器想必大家都有見到過吧,記錄每一個(gè)訪問者,下面有個(gè)不錯(cuò)的示例,感興趣的朋友可以參考下2014-01-01
JSP 自定義標(biāo)簽實(shí)現(xiàn)數(shù)據(jù)字典的實(shí)例
這篇文章主要介紹了JSP 自定義標(biāo)簽實(shí)現(xiàn)數(shù)據(jù)字典的實(shí)例的相關(guān)資料,這里實(shí)現(xiàn)這樣的功能,希望能幫助到大家,需要的朋友可以參考下2017-08-08

