Re: [問題] javascript控制page display
對不起 我自己解出來了... :$
基本上把這二組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
推
02/07 14:19, , 1F
02/07 14:19, 1F
→
02/07 14:20, , 2F
02/07 14:20, 2F
→
02/07 14:21, , 3F
02/07 14:21, 3F
討論串 (同標題文章)
完整討論串 (本文為第 2 之 2 篇):