I am not sure if I am explaining this correctly, or if I am even searching properly, but I cannot find an answer to my problem.
What I want to do is to have a set of options (links or buttons) on one section of the page (using select tags) that link to a single specific different portion of the page. This section will contain the contents of the div container specified by the link in the selection group. The page fits a screen and is not scroll-able in either direction, unless the user’s resolution is less than 1024×800.
I don’t have any code to show as I have not determined the final layout of the page yet, but I can give a simple representation of what the screen will look like. I am not asking anyone to write my code for me; rather, I am asking for help in how to write the javascript to make it work.
I do have some HTML code written for the display, but it does not contain the select routine yet as I was doing separate pages for each different div. I just thought that I could probably simplify things more if I could contain all the different div’s in one page and just select between them.
[code]
+—————-+————+————————————————+
| div select 1 | |This is the area that will hold the contents |
| div select 2 | |of the div selected by the button or link at |
| div select 3 | |the left. This area may or may not have a |
+—————-+ |vertical scroll bar, depending on the content |
| |of the div. This is an over-simplified diagram. |
| | |
| |I already know how to add the scroll bar to the |
| |div. |
| | |
+—————————–+————————————————+
<i>
</i><HTML>
<HEAD>
<TITLE>Sample Solution Page</TITLE>
<SCRIPT type="text/javascript">
function visInvis(id) {
var a = document.getElementById(mySol);
var b = document.getElementById(YASS);
var c = document.getElementById(Tak);
var e = document.getElementById(id);
if(e == a && e.style.display == 'none') {
b.style.display = 'none';
c.style.display = 'none';
}
if(e == b && e.style.display == 'none') {
a.style.display = 'none';
c.style.display = 'none';
}
if(e == c && e.style.display == 'none') {
a.style.display = 'none';
b.style.display = 'none';
}
if(e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';
}
</SCRIPT>
<STYLE>
#mySol { display: none; }
#YASS { display: none; }
#Tak { display: none; }
</STYLE>
</HEAD>
<BODY>
<TABLE align="left" valign="top" width="14%" cellspacing=0>
<TR><TH align="left" colspan="2">Puzzle Name</TH></TR>
<TR><TD>Width:</TD><TH>0</TH></TR>
<TR><TD>Height:</TD><TH>0</TH></TR>
<TR><TD>Boxes/Goals:</TD><TH>0/0</TH></TR>
<TR><TD colspan="2"><A onClick="visInvis('mySol');"><B>My Solution</B></A></TD></TR>
<TR><TD>Moves/Pushes:</TD><TH>0/0</TH></TR>
<TR><TD colspan="2"><A onClick="visInvis('YASS');"><B>YASS Solution</B></A></TD></TR>
<TR><TD>Moves/Pushes:</TD><TH>0/0</TH></TR>
<TR><TD colspan="2"><A onClick="visInvis('Tak');"><B>Takaken Solution</B></A></TD></TR>
<TR><TD>Moves/Pushes:</TD><TH>0/0</TH></TR>
</TABLE>
<TABLE align="left" valign="top" border="1" width="15%" height="300" cellspacing=0>
<CAPTION align="top"><B>Puzzle</B></CAPTION>
<TR><TD></TD></TR>
</TABLE>
<TABLE align="right" valign="top" border="1" width="70%" height="600" cellspacing=0>
<CAPTION align="top"><B>Solution</B></CAPTION>
<TR><TD valign="top">
<DIV id=mySol>My Solution</DIV>
<DIV id=YASS>YASS Solution</DIV>
<DIV id=Tak>Takaken Solution</DIV>
</TD></TR>
</TABLE>
</BODY>
</HTML>
<i>
</i><SCRIPT type="text/javascript">
function visInvis(id) {
var a = document.getElementById(mySol);
var b = document.getElementById(YASS);
var c = document.getElementById(Tak);
var e = document.getElementById(id);
if(a.style.display == 'block')
a.style.display = 'none';
if(b.style.display == 'block')
b.style.display = 'none';
if(c.style.display == 'block')
c.style.display = 'none';
if(e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';
}
</SCRIPT>
<i>
</i><HTML>
<HEAD>
<TITLE>Sample Solution Page</TITLE>
<SCRIPT type="text/javascript">
function visInvis(id) {
var a = document.getElementById('mySol');
var b = document.getElementById('YASS');
var c = document.getElementById('Tak');
var e = document.getElementById(id);
if(e == a && e.style.display == 'none') {
b.style.display = 'none';
c.style.display = 'none';
}
if(e == b && e.style.display == 'none') {
a.style.display = 'none';
c.style.display = 'none';
}
if(e == c && e.style.display == 'none') {
a.style.display = 'none';
b.style.display = 'none';
}
if(e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';
}
</SCRIPT>
<STYLE>
#mySol { display: none; }
#YASS { display: none; }
#Tak { display: none; }
</STYLE>
</HEAD>
<BODY>
<TABLE align="left" valign="top" width="14%" cellspacing=0>
<TR><TH align="left" colspan="2">Puzzle Name</TH></TR>
<TR><TD>Width:</TD><TH>0</TH></TR>
<TR><TD>Height:</TD><TH>0</TH></TR>
<TR><TD>Boxes/Goals:</TD><TH>0</TH></TR>
<TR><TD colspan="2"><A onClick="visInvis('mySol');"><B>My Solution</B></A></TD></TR>
<TR><TD>Moves/Pushes:</TD><TH>0/0</TH></TR>
<TR><TD colspan="2"><A onClick="visInvis('YASS');"><B>YASS Solution</B></A></TD></TR>
<TR><TD>Moves/Pushes:</TD><TH>0/0</TH></TR>
<TR><TD colspan="2"><A onClick="visInvis('Tak');"><B>Takaken Solution</B></A></TD></TR>
<TR><TD>Moves/Pushes:</TD><TH>0/0</TH></TR>
</TABLE>
<TABLE align="left" valign="top" border="1" width="15%" height="300" cellspacing=0>
<CAPTION align="top"><B>Puzzle</B></CAPTION>
<TR><TD></TD></TR>
</TABLE>
<TABLE align="right" valign="top" border="1" width="70%" height="600" cellspacing=0>
<CAPTION align="top"><B>Solution</B></CAPTION>
<TR><TD valign="top">
<DIV id=mySol>My Solution</DIV>
<DIV id=YASS>YASS Solution</DIV>
<DIV id=Tak>Takaken Solution</DIV>
</TD></TR>
</TABLE>
</BODY>
</HTML>
<i>
</i><!DOCTYPE HTML>
<HTML>
<HEAD>
<TITLE>Sample Solution Page</TITLE>
<SCRIPT type="text/javascript">
function visInvis(id) {
var a = document.getElementById('mySol');
var b = document.getElementById('YASS');
var c = document.getElementById('Tak');
var e = document.getElementById(id);
if(e == a && e.style.display == 'none') {
b.style.display = 'none';
c.style.display = 'none';
}
if(e == b && e.style.display == 'none') {
a.style.display = 'none';
c.style.display = 'none';
}
if(e == c && e.style.display == 'none') {
a.style.display = 'none';
b.style.display = 'none';
}
if(e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';
}
</SCRIPT>
<STYLE type="text/css">
#mySol { display: none; }
#YASS { display: none; }
#Tak { display: none; }
</STYLE>
</HEAD>
<BODY>
<TABLE align="left" valign="top" width="16%">
<TR><TH align="left" colspan="2">Puzzle Name</TH></TR>
<TR><TD>Width:</TD><TH width="50%">0</TH></TR>
<TR><TD>Height:</TD><TH width="50%">0</TH></TR>
<TR><TD>Boxes/Goals:</TD><TH width="50%">0</TH></TR>
<TR><TD colspan="2"><INPUT type="button" style="font-weight: bold;" onClick="visInvis('mySol');" value="My Solution"></TD></TR>
<TR><TD>Moves/Pushes:</TD><TH width="50%">0/0</TH></TR>
<TR><TD colspan="2"><INPUT type="button" style="font-weight: bold;" onClick="visInvis('YASS');" value="YASS Solution"></TD></TR>
<TR><TD>Moves/Pushes:</TD><TH width="50%">0/0</TH></TR>
<TR><TD colspan="2"><INPUT type="button" style="font-weight: bold;" onClick="visInvis('Tak');" value="Takaken Solution"></TD></TR>
<TR><TD>Moves/Pushes:</TD><TH width="50%">0/0</TH></TR>
</TABLE>
<TABLE align="left" valign="top" border="1" width="15%" height="300" cellspacing=0>
<CAPTION align="top"><B>Puzzle</B></CAPTION>
<TR><TD></TD></TR>
</TABLE>
<TABLE align="right" valign="top" border="1" width="68%" height="600" cellspacing=0>
<CAPTION align="top"><B>Solution</B></CAPTION>
<TR><TD valign="top">
<DIV id=mySol>My Solution</DIV>
<DIV id=YASS>YASS Solution</DIV>
<DIV id=Tak>Takaken Solution</DIV>
</TD></TR>
</TABLE>
</BODY>
</HTML>
[code=php]
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Title of the document</title>
<style>
.hid { display: none; }
</style>
</head>
<body>
<div id="btnwrap">
<button id="mysol">My Solution</button><br>
<button id="yasol">Yass Solution</button><br>
<button id="taksol">Tak Solution</button><br>
</div>
<div id="mysoldiv" class="hid">This is my Solution</div>
<div id="yasoldiv" class="hid">This is Yass Solution</div>
<div id="taksoldiv" class="hid">This is Tak Solution</div>
<script>
(function(){
var showndiv=false;
document.getElementById("btnwrap").onclick=function(e){
var e = e || window.event;
var targ = e.target || e.srcElement;
if(targ.tagName.toUpperCase()=="BUTTON"){
var thediv=document.getElementById(targ.id+"div");
if(showndiv){showndiv.className=showndiv.className+" hid"};
thediv.className=thediv.className.replace("hid","");
showndiv=thediv;
}
}
})();
</script>
</body>
</html>
[/code]
Here is a simple version of what I think you are trying to do.[/QUOTE]
[code=html]<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS "buttons"</title>
<style>
input {
display: none;
}
div {
line-height: 40px;
}
label {
background-color: gray;
padding: 3px;
margin: 2px;
color: #000;
font-weight: bold;
cursor: pointer;
border: 5px outset;
}
input[type=checkbox]:checked ~ label{ border: 5px inset; }
</style>
</head>
<body>
<div><input type="checkbox" id="mySolcontrol"><label for="mySolcontrol">My Solution</label></div>
<div><input type="checkbox" id="YASScontrol"><label for="YASScontrol">YASS Solution</label></div>
<div><input type="checkbox" id="Takcontrol"><label for="Takcontrol">Takaken Solution</label></div>
</body>
</html>[/code]
[code=html]<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS "buttons"</title>
<style>
input {
display: none;
}
div {
line-height: 40px;
}
label {
background-color: gray;
padding: 3px;
margin: 2px;
color: #000;
font-weight: bold;
cursor: pointer;
border: 5px outset;
}
input[type=radio]:checked ~ label{ border: 5px inset; }
</style>
</head>
<body>
<div><input type="radio" name="control" id="mySolcontrol"><label for="mySolcontrol">My Solution</label></div>
<div><input type="radio" name="control" id="YASScontrol"><label for="YASScontrol">YASS Solution</label></div>
<div><input type="radio" name="control" id="Takcontrol"><label for="Takcontrol">Takaken Solution</label></div>
<!-- a fourth button could be added here to clear everything and return the above buttons to "normal" -->
</body>
</html>[/code]
<i>
</i><!DOCTYPE HTML>
<HTML>
<HEAD>
<TITLE>Sample Solution Page</TITLE>
<SCRIPT type="text/javascript">
<!--
function visInvis(id,id1,id2,id3,id4,id5,id6) {
<i> </i> var a = document.getElementById('mySol');
<i> </i> var a1 = document.getElementById('MM');
<i> </i> var a2 = document.getElementById('MP');
<i> </i> var a3 = document.getElementById('MBL');
<i> </i> var a4 = document.getElementById('MBC');
<i> </i> var a5 = document.getElementById('MPS');
<i> </i> var a6 = document.getElementById('MPL');
<i> </i> var b = document.getElementById('YASS');
<i> </i> var b1 = document.getElementById('YM');
<i> </i> var b2 = document.getElementById('YP');
<i> </i> var b3 = document.getElementById('YBL');
<i> </i> var b4 = document.getElementById('YBC');
<i> </i> var b5 = document.getElementById('YPS');
<i> </i> var b6 = document.getElementById('YPL');
<i> </i> var c = document.getElementById('Tak');
<i> </i> var c1 = document.getElementById('TM');
<i> </i> var c2 = document.getElementById('TP');
<i> </i> var c3 = document.getElementById('TBL');
<i> </i> var c4 = document.getElementById('TBC');
<i> </i> var c5 = document.getElementById('TPS');
<i> </i> var c6 = document.getElementById('TPL');
<i> </i> var d;
<i> </i> var d1 = document.getElementById('MS');
<i> </i> var d2 = document.getElementById('YS');
<i> </i> var d3 = document.getElementById('TS');
<i> </i> var e = document.getElementById(id);
<i> </i> var e1 = document.getElementById(id1);
<i> </i> var e2 = document.getElementById(id2);
<i> </i> var e3 = document.getElementById(id3);
<i> </i> var e4 = document.getElementById(id4);
<i> </i> var e5 = document.getElementById(id5);
<i> </i> var e6 = document.getElementById(id6);
<i> </i> if(e == a && e.style.display == 'none') {
<i> </i> d = d1;
<i> </i> b.style.display = 'none';
<i> </i> b1.style.display = 'none';
<i> </i> b2.style.display = 'none';
<i> </i> b3.style.display = 'none';
<i> </i> b4.style.display = 'none';
<i> </i> b5.style.display = 'none';
<i> </i> b6.style.display = 'none';
<i> </i> d2.style.color = 'black';
<i> </i> c.style.display = 'none';
<i> </i> c1.style.display = 'none';
<i> </i> c2.style.display = 'none';
<i> </i> c3.style.display = 'none';
<i> </i> c4.style.display = 'none';
<i> </i> c5.style.display = 'none';
<i> </i> c6.style.display = 'none';
<i> </i> d3.style.color = 'black';
<i> </i> }
<i> </i> if(e == b && e.style.display == 'none') {
<i> </i> d = d2;
<i> </i> a.style.display = 'none';
<i> </i> a1.style.display = 'none';
<i> </i> a2.style.display = 'none';
<i> </i> a3.style.display = 'none';
<i> </i> a4.style.display = 'none';
<i> </i> a5.style.display = 'none';
<i> </i> a6.style.display = 'none';
<i> </i> d1.style.color = 'black';
<i> </i> c.style.display = 'none';
<i> </i> c1.style.display = 'none';
<i> </i> c2.style.display = 'none';
<i> </i> c3.style.display = 'none';
<i> </i> c4.style.display = 'none';
<i> </i> c5.style.display = 'none';
<i> </i> c6.style.display = 'none';
<i> </i> d3.style.color = 'black';
<i> </i> }
<i> </i> if(e == c && e.style.display == 'none') {
<i> </i> d = d3;
<i> </i> a.style.display = 'none';
<i> </i> a1.style.display = 'none';
<i> </i> a2.style.display = 'none';
<i> </i> a3.style.display = 'none';
<i> </i> a4.style.display = 'none';
<i> </i> a5.style.display = 'none';
<i> </i> a6.style.display = 'none';
<i> </i> d1.style.color = 'black';
<i> </i> b.style.display = 'none';
<i> </i> b1.style.display = 'none';
<i> </i> b2.style.display = 'none';
<i> </i> b3.style.display = 'none';
<i> </i> b4.style.display = 'none';
<i> </i> b5.style.display = 'none';
<i> </i> b6.style.display = 'none';
<i> </i> d2.style.color = 'black';
<i> </i> }
<i> </i> if(e == a && e.style.display == 'block')
<i> </i> d = d1;
<i> </i> if(e == b && e.style.display == 'block')
<i> </i> d = d2;
<i> </i> if(e == c && e.style.display == 'block')
<i> </i> d = d3;
<i> </i> if(e.style.display == 'block') {
<i> </i> e.style.display = 'none';
<i> </i> e1.style.display = 'none';
<i> </i> e2.style.display = 'none';
<i> </i> e3.style.display = 'none';
<i> </i> e4.style.display = 'none';
<i> </i> e5.style.display = 'none';
<i> </i> e6.style.display = 'none';
<i> </i> d.style.color = 'black';
<i> </i> }
<i> </i> else {
<i> </i> e.style.display = 'block';
<i> </i> e1.style.display = 'block';
<i> </i> e2.style.display = 'block';
<i> </i> e3.style.display = 'block';
<i> </i> e4.style.display = 'block';
<i> </i> e5.style.display = 'block';
<i> </i> e6.style.display = 'block';
<i> </i> d.style.color = 'teal';
<i> </i> }
<i> </i> }
<i> </i> function selectText(divID) //divID contains actual id of ‘div’ element
<i> </i> {
<i> </i> var textC=document.getElementById(divID);
<i> </i> if (document.selection)
<i> </i> {
<i> </i> //Portion for IE
<i> </i> var div = document.body.createTextRange();
<i> </i> div.moveToElementText(textC);
<i> </i> div.select();
<i> </i> }
<i> </i> else
<i> </i> {
<i> </i> //Portion for FF
<i> </i> var div = document.createRange();
<i> </i> div.setStartBefore(textC);
<i> </i> div.setEndAfter(textC);
<i> </i> window.getSelection().addRange(div);
<i> </i> }
<i> </i> }
<i> </i>-->
<i> </i></SCRIPT>
</HEAD>
<BODY>
<TABLE style="float: left; vertical-align: top; width: 17%;">
<TR><TH style="text-align: left; width: 65%;">Collection:</TH><TH style="width: 35%;">Revenge</TH></TR>
<TR><TH style="text-align: left;">Level #:</TH><TH style="width: 30%;">1</TH></TR>
<TR><TH style="text-align: left; vertical-align: top; height: 49.5pt;" colspan="2">Puzzle Name</TH></TR>
<TR><TD colspan="2"><HR></TD></TR>
<TR><TD>Width:</TD><TH style="width: 30%;">0</TH></TR>
<TR><TD>Height:</TD><TH style="width: 30%;">0</TH></TR>
<TR><TD>Boxes/Goals:</TD><TH style="width: 30%;">0</TH></TR>
<TR><TD colspan="2"><HR></TD></TR>
<TR><TD colspan="2" style="text-align: center;"><INPUT type="button" id=MS
style="font-weight: bold;" onMouseOver="this.style.color='teal'"
onMouseOut="this.style.color='black'"
onClick="visInvis('mySol','MM','MP','MBL','MBC','MPS','MPL');
selectText('mySol');" value="My Solution"></TD></TR>
<TR><TD colspan="2" style="text-align: center;"><INPUT type="button" id=YS
style="font-weight: bold;" onMouseOver="this.style.color='teal'"
onMouseOut="this.style.color='black'"
onClick="visInvis('YASS','YM','YP','YBL','YBC','YPS','YPL');
selectText('YASS');" value="YASS Solution"></TD></TR>
<TR><TD colspan="2" style="text-align: center;"><INPUT type="button" id=TS
style="font-weight: bold;" onMouseOver="this.style.color='teal'"
onMouseOut="this.style.color='black'"
onClick="visInvis('Tak','TM','TP','TBL','TBC','TPS','TPL');
selectText('Tak');" value="Takaken Solution"></TD></TR>
<TR><TD colspan="2"><HR></TD></TR>
<TR><TD>Moves:</TD><TH style="width: 30%;">
<DIV id=MM style="display: none;">0</DIV>
<DIV id=YM style="display: none;">0</DIV>
<DIV id=TM style="display: none;">0</DIV></TH></TR>
<TR><TD>Pushes:</TD><TH style="width: 30%;">
<DIV id=MP style="display: none;">0</DIV>
<DIV id=YP style="display: none;">0</DIV>
<DIV id=TP style="display: none;">0</DIV></TH></TR>
<TR><TD>Box lines:</TD><TH style="width: 30%;">
<DIV id=MBL style="display: none;">0</DIV>
<DIV id=YBL style="display: none;">0</DIV>
<DIV id=TBL style="display: none;">0</DIV></TH></TR>
<TR><TD>Box changes:</TD><TH style="width: 30%;">
<DIV id=MBC style="display: none;">0</DIV>
<DIV id=YBC style="display: none;">0</DIV>
<DIV id=TBC style="display: none;">0</DIV></TH></TR>
<TR><TD>Pushing sessions:</TD><TH style="width: 30%;">
<DIV id=MPS style="display: none;">0</DIV>
<DIV id=YPS style="display: none;">0</DIV>
<DIV id=TPS style="display: none;">0</DIV></TH></TR>
<TR><TD>Pusher lines:</TD><TH style="width: 30%;">
<DIV id=MPL style="display: none;">0</DIV>
<DIV id=YPL style="display: none;">0</DIV>
<DIV id=TPL style="display: none;">0</DIV></TH></TR>
<TR><TD colspan="2"><HR></TD></TR>
<TR><TD colspan="2">Inactive button means no solution available. Some puzzles YASS cannot solve,
some Takaken cannot solve, and some I have not solved.</TD></TR>
</TABLE>
<TABLE style="float: right; border: 1px solid; border-spacing: 0px; padding: 3px; vertical-align: top;
width: 42%; height: 650px;">
<CAPTION style="align: top; text-align: left; font-weight: bold;">Solution</CAPTION>
<TR><TD style="vertical-align: top;">
<DIV id=mySol style="display: none; width: 520px; height: 640px; word-wrap: break-word;
overflow: auto;">My Solution</DIV>
<DIV id=YASS style="display: none; width: 520px; height: 640px; word-wrap: break-word;
overflow: auto;">YASS Solution</DIV>
<DIV id=Tak style="display: none; width: 520px; height: 640px; word-wrap: break-word;
overflow: auto;">Takaken Solution</DIV>
</TD></TR>
</TABLE>
<TABLE style="float: center; border: 1px solid; border-spacing: 0px; padding: 3px; vertical-align: top;
width: 40.3%; height: 650px;">
<CAPTION style="align: top; text-align: left; font-weight: bold;">Puzzle</CAPTION>
<TR><TD>
<PRE style="text-align: center;"></PRE>
</TD></TR>
</TABLE>
</BODY>
</HTML>
<INPUT type="button" id=MS style="font-weight: bold;" onMouseOver="this.style.color='teal'" onMouseOut="this.style.color='black'" onClick="visInvis('mySol','MM','MP','MBL','MBC','MPS','MPL'); selectText('mySol');" value="My Solution">
[code=html]<button id="MS" onClick="visInvis('mySol','MM','MP','MBL','MBC','MPS','MPL'); selectText('mySol');">My Solution</button>[/code]
button {
font-weight: bold;
color: #000;
}
button:hover {
color: teal;
}
But all this (X 3-4):
<INPUT type="button" id=MS style="font-weight: bold;" onMouseOver="this.style.color='teal'" onMouseOut="this.style.color='black'" onClick="visInvis('mySol','MM','MP','MBL','MBC','MPS','MPL'); selectText('mySol');" value="My Solution">
could be replaced by:
[code=html]<button id="MS" onClick="visInvis('mySol','MM','MP','MBL','MBC','MPS','MPL'); selectText('mySol');">My Solution</button>[/code]
with this CSS;
button {
font-weight: bold;
color: #000;
}
button:hover {
color: teal;
}
And [b]text-align:left;[/b] is default for all elements. So unless you are counteracting a parent element's text alignment that's redundant.
There's probably more, but that's what stuck out to me... ?[/QUOTE]
[code=html]
<TR><TD colspan="2" style="text-align: center;"><INPUT type="button" id=MS
style="font-weight: bold;"
onClick="visInvis('mySol','MM','MP','MBL','MBC','MPS','MPL');
selectText('mySol');" value="My Solution"></TD></TR>
<TR><TD colspan="2" style="text-align: center;"><INPUT type="button" id=YS
style="font-weight: bold;"
onClick="visInvis('YASS','YM','YP','YBL','YBC','YPS','YPL');
selectText('YASS');" value="YASS Solution"></TD></TR>
<TR><TD colspan="2" style="text-align: center;"><INPUT type="button" id=TS
style="font-weight: bold;"
onClick="visInvis('Tak','TM','TP','TBL','TBC','TPS','TPL');
selectText('Tak');" value="Takaken Solution"></TD></TR>
[/code]
Since the color change on the rollover was not working, and I could not solve the issue, I opted to leave that part out. The buttons highlite when you move over them in the normal way (the background color changes slightly and the border color changes), and when you click a button the selected color (teal) is applied and remains until you click another button or the same button again.[/quote]
The text-align: left items are because I am overriding the normal behavior of the TH heading tag to center the text.[/quote]
I could have used <button> instead of <input type="button">, but I didn't want to chance that some hidden behavior of the <button> version would cause me problems.[/QUOTE]
[code=html]<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title of the document</title>
<style>
.hid, input {
display: none;
}
#btnwrap, #solutions {
display: inline-block;
vertical-align: top;
}
#btnwrap div {
width: 10em;
height: 2em;
}
label {
display: block;
background-color: light gray;
padding: 3px;
color: #000;
font-weight: bold;
cursor: pointer;
border: outset;
text-align: center;
}
label:hover {
color: teal;
}
input[type=radio]:checked ~ label{ border: inset; color: teal; }
</style>
</head>
<body>
<div id="btnwrap">
<div><input type="radio" name="control" id="mySolcontrol"><label for="mySolcontrol" id="mysol">My Solution</label></div>
<div><input type="radio" name="control" id="YASScontrol"><label for="YASScontrol" id="yasol">YASS Solution</label></div>
<div><input type="radio" name="control" id="Takcontrol"><label for="Takcontrol" id="taksol">Takaken Solution</label></div>
<div><input type="radio" name="control" id="hide" checked><label for="hide" id="hidden">Hide solutions</label></div>
</div>
<div id="solutions">
<div id="mysoldiv" class="hid">This is my Solution</div>
<div id="yasoldiv" class="hid">This is YASS Solution</div>
<div id="taksoldiv" class="hid">This is Takaken Solution</div>
<div id="hiddendiv" class="hid"></div> <!-- an empty DIV is kinda hacky but it works -->
</div>
<script>
(function(){
var showndiv=false;
document.getElementById("btnwrap").onclick = function(e){
var e = e || window.event,
targ = e.target || e.srcElement;
if(targ.tagName.toUpperCase() == "LABEL"){
var thediv = document.getElementById(targ.id+"div");
if(showndiv){
showndiv.className=showndiv.className+" hid";
}
thediv.className = thediv.className.replace("hid","");
showndiv = thediv;
}
}
})();
</script>
</body>
</html>[/code]
[CODE]<!DOCTYPE html>
<head>
<title>Toggle Demo</title>
<script language="JavaScript">
</html>var sw1
function startup() {
document.demo.dotoggle.style.color="red";
document.demo.dotoggle.style.backgroundColor="black";}
function calculate() {
sw1^= 1;
if (sw1) {
document.demo.dotoggle.style.color="black";
document.demo.dotoggle.style.backgroundColor="yellow";}
else {
document.demo.dotoggle.style.color="yellow";
document.demo.dotoggle.style.backgroundColor="black";
}
}
</script>
</head>
<body onload="startup()">
<form name="demo">
<input type="button" name="dotoggle" value="Toggle Me This" onclick="calculate(0)">
</form>
</body>
[/CODE]
Deleted by author.[/QUOTE]
If you are looking for a toggle button try:
...
At any rate, I find checkboxes and radio buttons give the user choices and let the user know what they are before clicking on the "Submit" button.[/QUOTE]
I deleted my first post since it seemed too much ego trip and too little addressing your question. My web site ishome.comcast.net , but look quickly since comcast will pull the plug on hobby (client side only) sites in October.
I also ask for help when I get stuck and got invaluable help in this forum for my tempo change and guitar chord pages (under NoteWorthy). The pages are all problems/questions I thought about or solved at one time or other and some are adaptations of other people's code (I [b]do[/b] give credit, though).
Just looked at my previous toggle code and have no idea why my {stop}html tag ended up on the fifth line instead of the bottom. At any rate, I made [B]sw1[/B] a global so it could be referenced by any other function, in case you or anyone else wants to use it outside of a demo page.
Good luck with your project.[/QUOTE]
0.1.9 — BETA 5.18