?
Solved

different confirm messages for different buttons

Posted on 2011-10-30
2
Medium Priority
?
244 Views
Last Modified: 2013-11-05
I have this confirm function, but I would like to be able to use different messages for different buttons.

As it is, only this: var message = "Really, for sure?" works. I put the other messages in vars, but I don't know how to access them.


function confirmSubmit(message){
                
                var editMess = "Press OK to confirm your edits.";
                var deleteMess =  "Are you sure you want to permanently delete this listing from the database?";
                
		var message = "Really, for sure?";
                
                var agree = confirm(message);
                    if (agree)
                            return true ;
                    else
                            return false ;
                }

Open in new window


these are my buttons, one for update, one for delete:

<a href='?delete={$data["mls"]}' onClick='return confirmSubmit()' class='deleteButton'>Delete</a>

<input type='submit' name='submit' value='Update' onClick='return confirmSubmit()'/>

Open in new window

     

Thanks,
Koza
0
Comment
Question by:Kyle Hamilton
2 Comments
 
LVL 9

Accepted Solution

by:
experts1 earned 2000 total points
ID: 37054546
You may try sending the message string from the onClick
function call from the button as below:

function confirmSubmit(message){

                var agree = confirm(message);
                    if (agree)
                            return true ;
                    else
                            return false ;
                }


<a href='?delete={$data["mls"]}' onClick="return confirmSubmit('Press OK to confirm your edits');" class='deleteButton'>Delete</a>

<a href='#' onClick="return confirmSubmit('Are you sure you want to permanently delete this listing from the database?');" class='deleteButton'>Delete</a>


<input type='submit' name='submit' value='Update' onClick="return confirmSubmit('Really, for sure?');"/>


0
 
LVL 25

Author Closing Comment

by:Kyle Hamilton
ID: 37054573
Thank You.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

750 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question