简体   繁体   中英

hide button after its been clicked

The issue I am having is that I want the submit button hidden after
I have chosen a date from a calendar. and submitted it. The html/script I am using is ...

<input type="button" value="Try it" id="Submit1"  onclick= "myFunction();this.form.submit();">

<script>
function myFunction() {
  var x = document.getElementById("Submit1");
  x.hidden= true;
}
</script>
...

When you have clicked the button it hides the button for a second but then appears again. I guess this when the page is reloaded. Anybody have a solution for this.

Its being written in Classic asp VB

try

  var x = document.getElementById("Submit1");
  x.style.visibility = "hidden";

https://www.w3schools.com/jsref/prop_style_visibility.asp

But this code should be executed after reloading the page, which means that the body of the new page just needs to have code

<script>
    window.myFunction();
</script>

The backend side (php, ruby, node ...) can take care of this.

You can call the code from the browser console (F12, then CTRL + `). This will give you a feel for what code you need to run and when.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM