Jump to content

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


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>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.