作者Toshiya (Kill me softly)
看板Web_Design
标题Re: [问题] javascript控制page display
时间Wed Feb 7 13:15:54 2007
对不起 我自己解出来了... :$
基本上把这二组checkbox设在不同的form里面就可以了
重点是那四个checkbox 一开始就要设style="visibility:hidden "
简言之 code长这样...
(虽然又设display又设visibility好像有点重复...@@)
<script language="javascript">
function select_all() {
document.form2.style.display="";
document.form2.style.visibility="visible";
document.form2.choice2.checked=true;
document.form2.choice3.checked=true;
document.form2.choice4.checked=true;
document.form2.choice5.checked=true;
}
function deselect_all(){
document.form2.style.display="none"; //not showing the form
document.form2.style.visibility="hidden";
document.form2.choice2.checked=false;
document.form2.choice3.checked=false;
document.form2.choice4.checked=false;
document.form2.choice5.checked=false;
}
</script>
<!-- in html -->
<form name="form1" >
<input name="choice1" type="checkbox" value="1" onclick="if (this.checked) {sel
ect_all();}else {deselect_all()}"> click me to see the other 4 choices
</form>
<form name="form2" style="visibility:hidden " >
<br><input name="choice2" type="checkbox" value="2"> choice 2
<br><input name="choice3" type="checkbox" value="3"> choice 3
<br><input name="choice4" type="checkbox" value="4"> choice 4
<br><input name="choice5" type="checkbox" value="5"> choice 5
</form>
--
抱歉 现丑了 :$
--
╭──╮╭──╮╭──╮╭╮╭╮╭──╮╭╮╭╮╭──╮
╰╮╭╯│╭╮││ ─┤│╰╯│╰╮╭╯│╰╯││ ○ │
││ │╰╯│├─ ││╭╮│╭╯╰╮╰╮╭╯│╭╮│
╰╯ ╰──╯╰──╯╰╯╰╯╰──╯ ╰╯ ╰╯╰╯
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 75.85.20.40
1F:推 TonyQ:这和form没有关系, 拿个div一样可以写 ,建议原PO充实DOM观念 02/07 14:19
2F:→ TonyQ:有些细节不好讲, 像是display可以取代visibility来用 :P 02/07 14:20
3F:→ TonyQ:呵 看有没有人能解释的清楚点罗 :P 上班中不好打码 02/07 14:21