Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Confirm Box - ASP Page - Onclick Event 1

Status
Not open for further replies.

teblack

Programmer
Apr 30, 2004
45
I have a page that I have a confirm box issue bases on a click of a delete button "Are you sure you want to delete"? Is is possible to wrap If logic around that confirm box logic.

I would like to test a selection box, to determine if the user has picked something from a that selection box first before I issue the "Are you Sure" confirm box. If the user fails to pick a selection from the box, I would like to issue a different confirm box asking "Please pick at least one from the Selection Box". If they have so then fire the "Are you Sure" confirmation box.

Here is my current button which needs to change -

Code:
<input type="submit" id="submit3" name="submit3" value="Delete" class="styleButton" onclick="javascript: if (confirm('Are you sure you want to delete your companies access rights to this website?')) document.CompanyView_Form.action.value= 'employer.actionDeleteCompany';  else return false;">

Thanks in advance for any help with this.

Thanks again,

TBlack -
 
Use curly brackets:
Code:
<input type="submit" id="submit3" name="submit3" value="Delete" class="styleButton" onclick="if(confirm('Are you sure you want to delete your companies access rights to this website?')){document.CompanyView_Form.action.value= 'employer.actionDeleteCompany'}else{return false;}">

But personally, I'd separate that out into a function and call the function.

Code:
<script>
function conf(f){
    if(confirm('Are you sure you want to delete your companies access rights to this website?')){
        f.action.value = 'employer.actionDeleteCompany';
        return true;
    } else {
        return false;
    }
}
</script>

<input type="submit" id="submit3" name="submit3" value="Delete" class="styleButton" onclick="return conf(this.form)">

Adam

There are only 10 types of people in the world: Those who understand binary, and those who don't
 
Adam: I gave you a star for that posting. I've been trying to get people to uncomplicate their event handlers by calling a function to do multiple steps for years. It's nice to get some back-up.


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top