Results 1 to 3 of 3

Thread: Calling Struts using Javascript

  1. #1
    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.

  2. #2
    Join Date
    Apr 2008
    Posts
    2,005

    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;
    }
    }

  3. #3
    Join Date
    Aug 2008
    Posts
    69

    Re: Calling Struts using Javascript

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

Similar Threads

  1. Struts 1 VS Struts 2
    By PsychoVillan in forum Software Development
    Replies: 6
    Last Post: 29-03-2011, 12:23 AM
  2. Calling a JavaScript function from Flash
    By Allison in forum Software Development
    Replies: 5
    Last Post: 08-02-2011, 04:58 PM
  3. Calling JavaScript from Managed Code
    By Computer_Freak in forum Tips & Tweaks
    Replies: 1
    Last Post: 03-08-2010, 03:31 PM
  4. Problem when calling a Javascript function
    By Truster in forum Software Development
    Replies: 5
    Last Post: 21-07-2010, 11:37 PM
  5. JSF versus Struts
    By Daksha in forum Software Development
    Replies: 3
    Last Post: 21-07-2010, 06:20 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,062,774.15313 seconds with 16 queries