Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

make submit button disappear when clicked

I wanted to know if there was a way I could adapt this code so that when the submit button was clicked, it would disappear, but the input box would remain.

<script type="text/javascript">

 var Text = 'hello';

    function setInput(button) {
       var buttonVal = button.name,
       textbox = document.getElementById('input_' + buttonVal);
       textbox.value = Text ;
    }
</script>

<html>
      <input class='input' id="input_a1" name="a1" value="<?php {echo $a1;} ?>"> 
      <input type='submit' name='a1' value='x' onclick='setInput(this); return false;'>
</html>
like image 564
user1559811 Avatar asked Oct 15 '25 22:10

user1559811


2 Answers

Simply add :

   button.style.visibility = "hidden";

at the end of your SetInput function.

like image 120
xlecoustillier Avatar answered Oct 18 '25 14:10

xlecoustillier


<button onclick="style.display = 'none'">Click Me</button>
like image 20
saikiran Avatar answered Oct 18 '25 14:10

saikiran



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!