• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Not able to call javascript function from struts tag

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I have a requirement like,I have to call a javascript function on onchange event of drop down box.
<tr>
<td height="20" align="center"><s:select label="Type* " id="groupType" cssStyle="width:125px" list="groupTypeMap"
name="group.groupType" onchange="javascript:enableOrDisableParentGroup();return false;" /></td>
</tr>


but here it is not calling the javascript method.

When I am directly giving alert() messages there itself it is working like:
<tr>
<td height="20" align="center"><s:select label="Type* " id="groupType" cssStyle="width:125px" list="groupTypeMap"
name="group.groupType" onchange="javascript:alert('ALERT MESSAGE');" /></td>
</tr>

Can you please tell me what is the exact way to call javascript function from struts tags.

Thanks
Lydia
 
Ranch Hand
Posts: 329
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lydia, use code tags it looks as good as below, easy to read and very simple to do it... isnt it?

Anyways, try removing "return false;" and just try as below,
 
lydia edward
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried the way you told but still it didn't work.
Can you please suggest me more ways.
 
Ranch Hand
Posts: 69
Eclipse IDE Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Paste your javascript function here
and check for any parameters it takes.
 
lydia edward
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Same issue I am facing here also.

<s:a id="url2" href="%{deleteUrlTag}" executeScripts="true" onclick="return confirm('Do you really want to delete this Remote machine?');" >Delete</s:a></td>

This is struts anchor tag.I am calling javascript confirm() message.When user click on yes then it should call the href url else in case of cancel it will not do anything. This tag is working fine.

But in place this I have to use struts dojo anchor tag because in that only I can specify the targets attribute.
so when I am trying with this:

<sx:a id="url2" href="%{deleteUrlTag}" executeScripts="true" onclick="return confirm('Do you really want to delete this Remote machine?');" >Delete</sx:a></td>

It is showing the confirm box, but in both the cases ok and cancel it is calling the href url.

1>For struts dojo tags is there different procedure to call the javascript function.
2> how can we call a seperate javascript function on these anchors onclick events.

Please help me on this.
Thanks in advance.



 
Shankar Tanikella
Ranch Hand
Posts: 329
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure about the "struts dojo tags" but there is no dependency among the action attributes href and onclick that are being used. They are working as they should.
May be you can do one thing.
Instead of having a confirm directly, call a javascript function which has it and drive the href based on user confirmation.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic