Click to See Complete Forum and Search --> : JS confirm


jayke00
11-24-2003, 04:02 PM
Hey,

Im rather new to JS and have a simple quesiton about a confirm script Im trying to use in some forms. The code is as follows:

<SCRIPT LANGUAGE="JavaScript">
function askData() {
var agree=confirm("Do you want to continue?");
if (agree)
return true ;
else
return false ;
}
</SCRIPT>

Im using the confirm script to ask the user if they want to continue when they click on the submit button. My problem is that i have multiple forms and buttons on the page, and Im wanting to change the question that is asked depending on which one they click. So what I need is some way send the variable from the button to the "Do you want to continue?" area in the function.

Does anyone know how I could do this?

Thanks :)

jayke00
11-24-2003, 05:40 PM
I figured it out. If anyone was wondering I used the following script:

<SCRIPT LANGUAGE="JavaScript">
function askData(changingtext) {
var agree=confirm(changingtext);
if (agree)
return true ;
else
return false ;
}
</SCRIPT>

and then added this to my form tag:

onSubmit="return askData('Do you want to continue?')"

Now I can change the confirm message for each separate form :)