Skip to main content
Inspiring
April 17, 2007
Answered

Show Hide Element Problem

  • April 17, 2007
  • 1 reply
  • 437 views
i am are trying to do something that can be achieved with Javascript.

<script language="javascript">
function showHideComment(onOff){
if (onOff == 1){
document.getElementById('commentArea').style.display = "";
} else {
document.getElementById('commentArea').style.display = "none";
}
}
</script>

<input type="radio" name="comment1" value="1" onClick="showHideComment(this.value);"> On <br/>
<input type="radio" name="comment1" value="0" onClick="showHideComment(this.value);"> Off

<cfoutput query="showcomment">
<table width="100%" border="0" align="center" id="commentArea">
<tr>
<td>Subject:</td>
<td><b class="sidebar">#subject#</b></td>
</tr>
</table>
</cfoutput>

but problem lies here when it:

hides only one Section of Comments, What about if i had more than 10 comments.

i tried changes the variables but no luck

plz help
    This topic has been closed for replies.
    Correct answer gavy81
    Thanks it worked..

    1 reply

    Inspiring
    April 17, 2007
    Hi,

    Just put your <cfoutput query> statement below the <table> tag (that is before the start of <tr> tag and it will do that..


    <cfquery name="showcomment" datasource="dav">
    select * from ttest;
    </cfquery>

    <script language="javascript">
    function showHideComment(onOff){
    if (onOff == 1){
    document.getElementById('commentArea').style.display = "";
    } else {
    document.getElementById('commentArea').style.display = "none";
    }
    }
    </script>

    <input type="radio" name="comment1" value="1" onClick="showHideComment(this.value);"> On <br/>
    <input type="radio" name="comment1" value="0" onClick="showHideComment(this.value);"> Off


    <table width="100%" border="0" align="center" id="commentArea">
    <cfoutput query="showcomment">
    <tr>
    <td>Subject:</td>
    <td><b class="sidebar">#firstname#</b></td>
    </tr>
    </cfoutput>
    </table>
    gavy81AuthorCorrect answer
    Inspiring
    April 18, 2007
    Thanks it worked..