user2431727
user2431727

Reputation: 907

Hide button after confirmation in php

I have created a button.It will show a Yes/No confirmation box when clicks on it.I want to hide the button when user clicks on 'Yes' button.My code is here

 <input type="button" name='hide_button' id='hide_button' value="Hide?"onClick="return confirm_hide();">  

Javascript :

function confirm_hide(){
if(confirm('Do you wish to hide the button?'))
    return true;
else return false;
}

Upvotes: 1

Views: 354

Answers (3)

Ehsan Ilahi
Ehsan Ilahi

Reputation: 298

this function will help you

function confirm_hide() {
  if (confirm('Do you wish to hide the button?')) {
      $("#hide_button").hide();
    return true;
  } else return false;
}

Thank you...

Upvotes: 0

Azad
Azad

Reputation: 5264

the following code help you add your button element id inplace

function confirm_delete(){
if(confirm('Do you wish to hide the button?')){
    var yesBtn = document.getElementById('yesBtn');
        yesBtn.style.display = 'none';
    return true;
}
else 
    return false;
}

Upvotes: 1

Pranav C Balan
Pranav C Balan

Reputation: 115232

Update the display style property to none.

function confirm_hide(ele) {
  if (confirm('Do you wish to hide the button?')) {
    ele.style.display = 'none';
    return true;
  } else return false;
}
<input type="button" name='hide_button' id='hide_button' value="Hide?" onClick="return confirm_hide(this);">

Upvotes: 2

Related Questions