Darshita Paghadal
Darshita Paghadal

Reputation: 39

php echo javascript textbox hide not work

i am trying to show or hide the textbox or form of html while clicking on link button which is generated via echo php statement..

but it does not work..

<script>
function onHide()
{
    alert("hide");
    document.getElementById("txt").style.display = "block";
    $("#txt").show();
} 
</script>

<body>
    <input type="text" name="txt" id="txt" style="display: none;">
    <input id="btn" value="hide/show" type="button" "value="hide/show" onclick="onHide()" /><!-- here onHide works -->

<?php
echo "<br/><a onclick='onHide()' id=".$row['id'].">Edit</a>";//this does not work..
?>


</body>

please anyone help me.. where is my mistake?

Upvotes: 0

Views: 227

Answers (2)

Apoorv
Apoorv

Reputation: 231

Correct value "

<input id="btn" type="button" value="hide/show" onclick="onHide()" />

And Use below script

<script>
function onHide()
{
    alert("hide");
    $("#txt").toggle();
} 
</script>

Also include jQuery if not included on the page

Upvotes: 1

Dmitry Ivanov
Dmitry Ivanov

Reputation: 94

Mistake in syntax:

Your wrote:

type="button" "value="hide/show"

But need:

type="button" value="hide/show"

Upvotes: 0

Related Questions