ここの表示を「表示・非表示」ボタンで表示・非表示する
←
<html>
<script language="javascript">
<!--
function getElm(tName){
var obj=null;
if(document.all || document.getElementById) {
if(document.all) {
obj=document.all(tName);
} else {
obj=document.getElementById(tName);
}
} else {
if(document.layers) {
obj=document.layers(tName);
}
}
return obj;
}
function changeDisp(tName){
var elm=getElm(tName).style;
elm.display = (elm.display!='block') ? 'block' : 'none';
}
//-->
</script>
<body>
<form name="testform">
<INPUT TYPE="button" Value="表示・非表示" onClick="changeDisp('test')">
</form>
→<p id="test" style="DISPLAY:block">ここの表示を「表示・非表示」ボタンで表示・非表示する</p>←
</body>
</html>
<form name="testform">
<INPUT TYPE="button" Value="親の下を表示・非表示" onClick="changeDisp('test0')"><br>
<INPUT TYPE="button" Value="子1の下を表示・非表示" onClick="changeDisp('test1')">
<INPUT TYPE="button" Value="子2の下を表示・非表示" onClick="changeDisp('test2')">
<INPUT TYPE="button" Value="孫11の下を表示・非表示" onClick="changeDisp('test11')">
<INPUT TYPE="button" Value="孫12の下を表示・非表示" onClick="changeDisp('test12')">
<INPUT TYPE="button" Value="孫21の下を表示・非表示" onClick="changeDisp('test21')">
<INPUT TYPE="button" Value="孫22の下を表示・非表示" onClick="changeDisp('test22')">
</form>
+親<br>
<div id="test0" style="display:block">
+子1<br>
<div id="test1" style="display:block">
+孫11<br>
<div id="test11" style="display:block">
・ひ孫111<br>
</div>
+孫12<br>
<div id="test12" style="display:block">
・ひ孫121<br>
</div>
</div>
+子2<br>
<div id="test2" style="display:block">
+孫21<br>
<div id="test21" style="display:block">
・ひ孫211<br>
</div>
+孫22<br>
<div id="test22" style="display:block">
・ひ孫221<br>
</div>
</div>
</div>
<script language="javascript">
<!--
function getName() { return this.Name_ }
function getURL() { return this.URL; }
function getContent() { return this.Content; }
function Content(tContentName, tURL) {
var ContentName;
var URL;
this.ContentName = tContentName;
this.URL = tURL;
ContentName = getName;
URL = getURL;
}
function Contents(tContentsName, tURL, objContent) {
var ContentsName;
var URL;
var Content;
this.ContentsName = tContentsName;
this.URL = tURL;
this.Content = objContent;
ContentsName = getName;
URL = getURL;
Content = getContent;
}
listContents=new Array(3);
listContent=new Array(2);
listContent[0]=new Content("test11", "test11.html");
listContent[1]=new Content("test12", "test12.html");
listContents[0] = new Contents("Test01", "test1.html", listContent);
listContent=new Array(2);
listContent[0]=new Content("test21", "test21.html");
listContent[1]=new Content("test22", "test22.html");
listContents[1] = new Contents("Test02", "Test2.html", listContent);
listContent=new Array(2);
listContent[0]=new Content("test31", "test31.html");
listContent[1]=new Content("test32", "test32.html");
listContents[2] = new Contents("Test03", "Test3.html", listContent);
for(i=0; listContents.length > i; i++) {
objContents = listContents[i];
document.write('<A onclick="javaScript:changeDisp('+ "'" , objContents.ContentsName, "')" + '" class="Brunch">');
document.write('<span id="', objContents.ContentsName + '_', '" style="cursor:hand;">+</span>');
document.write('</A>');
document.write('<A href="', objContents.URL, '" target="_blank">', objContents.ContentsName, '</A><br>');
document.write('<div id="', objContents.ContentsName, '" style="DISPLAY:none">');
listContent = objContents.Content;
for(j=0; listContent.length > j; j++) {
objContent=listContent[j];
document.write('<p class="Nowrap">');
if(listContent.length-1 != j) {
document.write('├');
} else {
document.write('└');
}
document.write('<A href="', objContent.URL, '" target="_blank">', objContent.ContentName, '</A></p>');
}
document.write('</div>');
}
// -->
</script>