RE: Passing variable to javascript function

2005-08-29 Thread BHansard

You can also use JSTL Notation.





Leon Rosenberg <[EMAIL PROTECTED]>








Leon Rosenberg <[EMAIL PROTECTED]> 
08/29/2005 06:39 AM

Please respond to
"Struts Users Mailing List" 








To
user@struts.apache.org


cc



Subject
RE: Passing variable to _javascript_ function








Unfortunately it's not so easy, because you can't use a tag as an
attribute to the tag.

 validateDelete()" 

This can't work, because the attribute (onclick) will not be evaluated.

There could be two possible solutions. First, leave the html taglib and
drop back to normal 

Second: store the variable value in a _javascript_ variable:

var myData = '';
validateDelete(myData)" Of course this only works if you have the value of myData at page generating time. If the value is changed by something the user does on page, like checking a checkbox, i would store it in a hidden field in the form and read per _javascript_ in validateDelete(), like this: for (var i=0;i < document.formname.elements.length;i++){   var e = document.formname.elements[i];   if (e.value == 'set' && e.checked==true){ doSubmit=true; myData = e.value;   } } the above _javascript_ is only an example how to iterate over form fields with _javascript_, it has not the required functionality. regards Leon On Mon, 2005-08-29 at 14:28 +0530, Anjishnu Bandyopadhyay wrote: > Hi Anuradha, > > > > I think this will work: > > > > validateDelete('')" > > where "abc" is the java variable that you put in request/session. > > > > With best regards, > > Anjishnu. > > > > -Original Message- > From: Anuradha S.Athreya [mailto:[EMAIL PROTECTED] > Sent: Monday, August 29, 2005 2:26 PM > To: [EMAIL PROTECTED] Apache. Org > Subject: Passing variable to _javascript_ function > > > > > > I had posted this problem a few days back, but I couldn't find a > solution to > > this. > > So I'm posting this again, since I need to implemen this urgently. > > > > >
>
> > function validateDelete()
>
> > {
>
> >          return confirm("Delete Data");    
>
> > }
>
> >       > > > > > > > > >           > scope="page" > > > validateDelete()" > > > >                                              Delete Data > > >                                   > > > > > >          To the validateDelete() _javascript_ function, I want to pass a > java > > > variable. How do I do it? > > >          Once I pass the variable, my _javascript_ function has to be : > > > > > >                      
>
> > function validateDelete(data)
>
> > {
>
> >          return confirm("Delete Data"+data);        
>
> > }
>
> >       > > > > CAUTION - Disclaimer * > This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Infosys has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus checks before opening the e-mail or attachment. Infosys reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the Infosys e-mail system. > ***INFOSYS End of Disclaimer INFOSYS*** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

RE: Passing variable to javascript function

2005-08-29 Thread Anuradha S.Athreya
Thanks , this was very informative.

Regards
Anuradha 

-Original Message-
From: Leon Rosenberg [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 29, 2005 4:09 PM
To: user@struts.apache.org
Subject: RE: Passing variable to javascript function

Unfortunately it's not so easy, because you can't use a tag as an attribute
to the tag.
)" 

This can't work, because the attribute (onclick) will not be evaluated.

There could be two possible solutions. First, leave the html taglib and drop
back to normal 
 var myData = '';   Hi Anuradha,
> 
> 
> 
> I think this will work:
> 
> 
> 
> onclick="return validateDelete('')"
> 
> where "abc" is the java variable that you put in request/session.
> 
> 
> 
> With best regards,
> 
> Anjishnu.
> 
> 
> 
> -Original Message-
> From: Anuradha S.Athreya [mailto:[EMAIL PROTECTED]
> Sent: Monday, August 29, 2005 2:26 PM
> To: [EMAIL PROTECTED] Apache. Org
> Subject: Passing variable to javascript function
> 
> 
> 
> 
> 
> I had posted this problem a few days back, but I couldn't find a 
> solution to
> 
> this.
> 
> So I'm posting this again, since I need to implemen this urgently.
> 
> 
> 
> > 
> 
> > function validateDelete()
> 
> > {
> 
> >  return confirm("Delete Data");
> 
> > }
> 
> >   
> 
> >
> 
> >
> 
> >   scope="page"
> 
> > onclick="return validateDelete()" >
> 
> >  Delete Data
> 
> >  
> 
> >
> 
> >  To the validateDelete() Javascript function, I want to pass 
> > a
> java
> 
> > variable. How do I do it?
> 
> >  Once I pass the variable, my javascript function has to be :
> 
> >
> 
> >  
> 
> > function validateDelete(data)
> 
> > {
> 
> >  return confirm("Delete Data"+data);
> 
> > }
> 
> >   
> 
> 
> 
>  CAUTION - Disclaimer * This e-mail 
> contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the
use of the addressee(s). If you are not the intended recipient, please
notify the sender by e-mail and delete the original message. Further, you
are not to copy, disclose, or distribute this e-mail or its contents to any
other person and any such actions are unlawful. This e-mail may contain
viruses. Infosys has taken every reasonable precaution to minimize this
risk, but is not liable for any damage you may sustain as a result of any
virus in this e-mail. You should carry out your own virus checks before
opening the e-mail or attachment. Infosys reserves the right to monitor and
review the content of all messages sent to or from this e-mail address.
Messages sent to or from this e-mail address may be stored on the Infosys
e-mail system.
> ***INFOSYS End of Disclaimer INFOSYS***



-
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]



RE: Passing variable to javascript function

2005-08-29 Thread Leon Rosenberg
Unfortunately it's not so easy, because you can't use a tag as an
attribute to the tag.
)" 

This can't work, because the attribute (onclick) will not be evaluated.

There could be two possible solutions. First, leave the html taglib and
drop back to normal 
 var myData = '';

 Hi Anuradha,
> 
> 
> 
> I think this will work:
> 
> 
> 
> onclick="return validateDelete('')"
> 
> where "abc" is the java variable that you put in request/session.
> 
> 
> 
> With best regards,
> 
> Anjishnu.
> 
> 
> 
> -Original Message-
> From: Anuradha S.Athreya [mailto:[EMAIL PROTECTED]
> Sent: Monday, August 29, 2005 2:26 PM
> To: [EMAIL PROTECTED] Apache. Org
> Subject: Passing variable to javascript function
> 
> 
> 
> 
> 
> I had posted this problem a few days back, but I couldn't find a
> solution to
> 
> this.
> 
> So I'm posting this again, since I need to implemen this urgently.
> 
> 
> 
> > 
> 
> > function validateDelete()
> 
> > {
> 
> >  return confirm("Delete Data");
> 
> > }
> 
> >   
> 
> >
> 
> >
> 
> >   scope="page"
> 
> > onclick="return validateDelete()" >
> 
> >  Delete Data
> 
> >  
> 
> >
> 
> >  To the validateDelete() Javascript function, I want to pass a
> java
> 
> > variable. How do I do it?
> 
> >  Once I pass the variable, my javascript function has to be :
> 
> >
> 
> >  
> 
> > function validateDelete(data)
> 
> > {
> 
> >  return confirm("Delete Data"+data);
> 
> > }
> 
> >   
> 
> 
> 
>  CAUTION - Disclaimer *
> This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely 
> for the use of the addressee(s). If you are not the intended recipient, 
> please notify the sender by e-mail and delete the original message. Further, 
> you are not to copy, disclose, or distribute this e-mail or its contents to 
> any other person and any such actions are unlawful. This e-mail may contain 
> viruses. Infosys has taken every reasonable precaution to minimize this risk, 
> but is not liable for any damage you may sustain as a result of any virus in 
> this e-mail. You should carry out your own virus checks before opening the 
> e-mail or attachment. Infosys reserves the right to monitor and review the 
> content of all messages sent to or from this e-mail address. Messages sent to 
> or from this e-mail address may be stored on the Infosys e-mail system.
> ***INFOSYS End of Disclaimer INFOSYS***



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



RE: Passing variable to javascript function

2005-08-29 Thread Anjishnu Bandyopadhyay

Hi Anuradha,



I think this will work:



onclick="return validateDelete('')"

where "abc" is the java variable that you put in request/session.



With best regards,

Anjishnu.



-Original Message-
From: Anuradha S.Athreya [mailto:[EMAIL PROTECTED]
Sent: Monday, August 29, 2005 2:26 PM
To: [EMAIL PROTECTED] Apache. Org
Subject: Passing variable to javascript function





I had posted this problem a few days back, but I couldn't find a
solution to

this.

So I'm posting this again, since I need to implemen this urgently.



> 

> function validateDelete()

> {

>  return confirm("Delete Data");

> }

>   

>

>

>   onclick="return validateDelete()" >

>  Delete Data

>  

>

>  To the validateDelete() Javascript function, I want to pass a
java

> variable. How do I do it?

>  Once I pass the variable, my javascript function has to be :

>

>  

> function validateDelete(data)

> {

>  return confirm("Delete Data"+data);

> }

>   



 CAUTION - Disclaimer *
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely 
for the use of the addressee(s). If you are not the intended recipient, please 
notify the sender by e-mail and delete the original message. Further, you are 
not to copy, disclose, or distribute this e-mail or its contents to any other 
person and any such actions are unlawful. This e-mail may contain viruses. 
Infosys has taken every reasonable precaution to minimize this risk, but is not 
liable for any damage you may sustain as a result of any virus in this e-mail. 
You should carry out your own virus checks before opening the e-mail or 
attachment. Infosys reserves the right to monitor and review the content of all 
messages sent to or from this e-mail address. Messages sent to or from this 
e-mail address may be stored on the Infosys e-mail system.
***INFOSYS End of Disclaimer INFOSYS***