Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 25-10-2008
Member
 
Join Date: Aug 2008
Posts: 69
Calling Struts using Javascript

My web page has a drop down box, and I want to call struts action as soon as the value changes from the drop down. (Basically submit a form using JavaScript on "onchange" event of dropdown)

Can someone give me a direction for such JavaScript?

example would be

JSP
Code:
<html:form action="/someAction" method="POST">

Struts-config.xml
<action path="/someAction" type="com.SomeAction" name="someForm"
parameter="action" scope="request" input="someinput">
<forward name="someLocalActn"
path="/someAction?action=display"></forward>
</action>
Thanks.
Reply With Quote
  #2  
Old 25-10-2008
Member
 
Join Date: Apr 2008
Posts: 2,001
Re: Calling Struts using Javascript

I think you can do it like this:

Code:
<html:select onclick="javascript:doABC(this);">
....

....

<script language="javascript">

function doABC(sel) {
var form = document.forms[i];//here i depends on which form you want
to submit.
//or you can define it in
the case sentence.
switch(sel.value) {
case "A":
form.action = "...";
form.submit();
break;
case "B":
form.action = "...";
form.submit();
break;
case "C":
form.action = "...";
form.submit();
break;
}
}
Reply With Quote
  #3  
Old 25-10-2008
Member
 
Join Date: Aug 2008
Posts: 69
Re: Calling Struts using Javascript

I am getting "Object doesn't support this property or method"
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags:



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Calling Struts using Javascript"
Thread Thread Starter Forum Replies Last Post
Struts 1 VS Struts 2 PsychoVillan Software Development 6 29-03-2011 12:23 AM
Calling a JavaScript function from Flash Allison Software Development 5 08-02-2011 04:58 PM
Calling JavaScript from Managed Code Computer_Freak Tips & Tweaks 1 03-08-2010 03:31 PM
Problem when calling a Javascript function Truster Software Development 5 21-07-2010 11:37 PM
JSF versus Struts Daksha Software Development 3 21-07-2010 06:20 AM


All times are GMT +5.5. The time now is 12:37 AM.