huyden181
06-20-2012, 10:38 AM
I want to show and hide div but i have a problem
<script type="text/javascript">
function showstuff(boxid){
document.getElementById(boxid).style.visibility="visible";
}
function hidestuff(boxid){
document.getElementById(boxid).style.visibility="hidden";
}
</script>
<div id="click_text_and_hide_me" style="visibility: visible">
<a href="#" onclick="showstuff('selectionA');hidestuff('click_text_and_hide_me')">A</a><br>
<a href="#" onclick="showstuff('selectionB');hidestuff('click_text_and_hide_me')">B</a></div>
<div id="solution" style="visibility: hidden">Here is the solution</div>
<div id="selectionA" style="visibility: hidden">
You clicked the selection A<br>
<script type="text/javascript">
var x="variable_inputed";
if( x === "variable_compare"){
document.write("<b>That's Right</b>");
}else{
document.write("<b>False</b><br><a href="#" onclick="showstuff('solution')">Click here to see the solution</a>);
}
</script>
</div>
<==div selentionB is the same==>
When I use
<a href="#" onclick="showstuff('solution')">Click here to see the solution</a>
in document.write in the "IF ELSE" command. It doesn't work. so in "ELSE", How do I have to do with my aim? ( show div "solution" )
<script type="text/javascript">
function showstuff(boxid){
document.getElementById(boxid).style.visibility="visible";
}
function hidestuff(boxid){
document.getElementById(boxid).style.visibility="hidden";
}
</script>
<div id="click_text_and_hide_me" style="visibility: visible">
<a href="#" onclick="showstuff('selectionA');hidestuff('click_text_and_hide_me')">A</a><br>
<a href="#" onclick="showstuff('selectionB');hidestuff('click_text_and_hide_me')">B</a></div>
<div id="solution" style="visibility: hidden">Here is the solution</div>
<div id="selectionA" style="visibility: hidden">
You clicked the selection A<br>
<script type="text/javascript">
var x="variable_inputed";
if( x === "variable_compare"){
document.write("<b>That's Right</b>");
}else{
document.write("<b>False</b><br><a href="#" onclick="showstuff('solution')">Click here to see the solution</a>);
}
</script>
</div>
<==div selentionB is the same==>
When I use
<a href="#" onclick="showstuff('solution')">Click here to see the solution</a>
in document.write in the "IF ELSE" command. It doesn't work. so in "ELSE", How do I have to do with my aim? ( show div "solution" )