Jump to content

[SOLVED] How do i make a table visable and not visable by a button??


iceman023

Recommended Posts

The code below will show/hide the contents of a div when clicking the button. Put your form inside the div.

 

<input type="button" value="Show Comment" onclick="toggleComment()" id="toggle_button">
<div id="comment_area" style="display:none;">

put your form with textboxes in here

</div>

<script type="text/javascript">

function toggleComment()
{
    var commentArea = document.getElementById("comment_area");    
    var toggleButton = document.getElementById("toggle_button");

    if(label == "Show Comment")
    {
        commentArea.style.display = ""; //show it
        toggleButton.value = "Hide Comment";
    }
    else
    {
        commentArea.style.display = "none"; //hide it
        toggleButton.value = "Show Comment";
    }
}

</script>

Thanks, but i have this and nothing happens.. did i do something wrong?

 

<html>
<head>
<title></title>
<script type="text/javascript">
function toggleComment()
{
    var commentArea = document.getElementById("comment_area");    
    var toggleButton = document.getElementById("toggle_button");

    if(label == "Show Comment")
    {
        commentArea.style.display = ""; //show it
        toggleButton.value = "Hide Comment";
    }
    else
    {
        commentArea.style.display = "none"; //hide it
        toggleButton.value = "Show Comment";
    }
}

</script>


</head>
<body>
<input type="button" value="Show Comment" onclick="toggleComment()" id="toggle_button">
<div id="comment_area" style="display:none;">

<form name="form1" method="post" action="">
<center>
  <label for="Show Comment"></label>
  <p>
    <textarea name="reply" cols="40" rows="5" id="reply"></textarea>
  </p>
  <p>Replied By: </p>
  <p>
    <label for="textfield"></label>
    <input name="AuthorReply" type="text" id="AuthorReply" size="40">
    <label for="Submit"></label>
    <input type="submit" name="Submit" value="Submit" id="Submit">
  </p></center>
</form>
</div>


</body>
</html>

No, not you. the182guy make an booboo.

 

<html>
<head>
<title></title>
<script type="text/javascript">
function toggleComment() {
    var commentArea = document.getElementById("comment_area");
    commentArea.style.display = commentArea.style.diplay == ""? "none" : "";
}
</script>


</head>
<body>
<input type="button" value="Show Comment" onclick="toggleComment()" id="toggle_button">
<div id="comment_area" style="display:none;">

<form name="form1" method="post" action="">
<center>
  <label for="Show Comment"></label>
  <p>
    <textarea name="reply" cols="40" rows="5" id="reply"></textarea>
  </p>
  <p>Replied By: </p>
  <p>
    <label for="textfield"></label>
    <input name="AuthorReply" type="text" id="AuthorReply" size="40">
    <label for="Submit"></label>
    <input type="submit" name="Submit" value="Submit" id="Submit">
  </p></center>
</form>
</div>


</body>
</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.