Doing what you suggested results in a Confirm Box with Text = <%=jsMessage%>

Is something wrong with my JS function. 

Here it is:

<script type="text/javascript">
function confirmationMessage(message)
{
var agree = confirm(message);
if (agree)
        return true ;
else
        return false ;
}

</script>

-----Original Message-----
From: 皮苗 [mailto:[EMAIL PROTECTED] 
Sent: Friday, September 08, 2006 11:38 AM
To: Struts Users Mailing List
Subject: Re: Setting a Variable in Javascript Functions parameter

Is jsMessage a java variable or a javascript variable? If it's a java
variable and you want to pass its value to the javascript function, I think
"onclick=return confirmationMessage('<%=jsMessage%>');" will work. The
quotes inside the parentheses shouldn't be omitted.


2006/9/8, Chetan Pandey <[EMAIL PROTECTED]>:
>
> Hi Puneet:
>
> None of the suggestions worked.
>
> I even tried
> "onclick =returnconfirmationMessage(<%=jsMessage%>)"
>
> And other combinations with no help.
>
> Thanks.
>
> Chetan
>
> -----Original Message-----
> From: Puneet Lakhina [mailto:[EMAIL PROTECTED]
> Sent: Thursday, September 07, 2006 11:13 PM
> To: Struts Users Mailing List
> Subject: Re: Setting a Variable in Javascript Functions parameter
>
> On 9/7/06, nirav bumia <[EMAIL PROTECTED]> wrote:
> >
> > Just pass the variable jsMessage(remove the quotes)  i.e.
> > <html:link action="/delete" onclick="return
> > > confirmationMessage(jsMessage)">
> >
> > and use this variable in javascript.
>
>
> I suppose you are trying to pass a variable that you have in some scope in
> your jsp to your javascript function.
>
> Am not really sure the above suggested solution will work. Reason being
> there is no way for struts(or your jsp processor) to know if this is
> variable isnt actually a javascript variable.
>
> I would use something like this
>
> <html:link action="/delete" onclick =
> '<%="returnconfirmationMessage(jsMessage)" %>'
>
> Try it and let us know what happens.
> --
> Puneet
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to