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.
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;
}
}
Re: Calling Struts using Javascript
I am getting "Object doesn't support this property or method"