Reputation: 279
I know this question has been asked before multiple times on StackOverFlow. I have implemented a method to generate a text box for Button click event. But my issue is text box is already visible before performing the clicking. I need to view the text-box when someone clicks the button. I'll put my coding down below.
Coding for the text-field
<div id="inputField" style="display:none;">
<input type="text" id="textInput" value="" />
</div>
Coding for the Button click event
<a href="" onclick="document.getElementById('inputField').style.display = 'block';">Click me</a>
Just to make more sense, I'll attach a screenshot of my coding and the graphical view of the form.
I'm kindly requesting from everyone not to mark this question as duplicate. I did my best to fix this issue by my own. Though I'm a newbie to this field I couldn't make it up. Any help would be really appreciated. Thank you!
Upvotes: 0
Views: 4599
Reputation: 32
Try the html with:
<form method="post" action="?btnpressed=1">
<a href="" name="btn">Click me</a>
</form>
And in the php:
<?php
if(isset($_GET['btnpressed']{
if(isset($_POST['btn']{ ?>
<div id="inputField" style="display:none;">
<input type="text" id="textInput" value="" />
</div>
<?php
}
}
?>
I hope this helps...
Upvotes: 1