Showing and hiding input

0

I have a button, when I click on it I want a field of type input , in that field, when I add some text I want it to go to the database, with a ALTER table . How do input appear and how do I get rid of it?

    
asked by anonymous 30.03.2016 / 23:44

1 answer

1

You can use jQuery to do this without much effort:

In html start your input as hidden.

<input type="text" id="seu-input" style="display:none">

Create a button to display input :

<button id="exibe-input">Meu botão</button>

And finally create a javascript function so that when the button is clicked it displays the field.

<script type="text/javascript">
$('#exibe-input').click(function(){
 $('#seu-input').css("display", "block");  
}
</script>

To hide the field another function can be created with the opposite action.

$('#seu-input').css("display", "none");

Source: The display property

    
31.03.2016 / 00:45