onChange:Execute JSP

Discussion in 'JavaScript' started by kunla, Jun 12, 2009.

  1. #1
    try to be more clear, i'm in lack of ideas in this problem.
    <logic:present name="StateList" scope="session">
    <td align="left"><font color="red"><b><b>*</b></b></font>&nbsp;<b>Select State</td>
    <td>
    <html:select  property="selectedState" onChange="execute(this.form)">
    <html:option value="-1">Select</html:option>
    <html:options collection="StateList" property="label" labelProperty="value" />
    </html:select>
    </td>
    </tr>
    <tr></tr>
    </logic:present>	
    
    HTML:
    on calling onChange i want to reload this JSP without refreshing parameter.Because On the basis of selected value i have to perform some other features.I am able to do using struts,but i dont want to use struts.
    using struts i can do like this:
    
    function execute(frm)
    {
        frm.action="Inedex.do?method=process";
        frm.submit();
    }
    
    HTML:
    process method is written in Indexaction.java.which is returning my same JSP(return mapping.findforward("this")).where "this" is mapped to Index.jsp and i am attaining my goal.But i dont want to use struts.
    I have spend hours trying to play around with this but have got nowhere.
    Your help is much appreciated.
     
    kunla, Jun 12, 2009 IP
  2. Unni krishnan

    Unni krishnan Peon

    Messages:
    237
    Likes Received:
    9
    Best Answers:
    2
    Trophy Points:
    0
    #2
    If you intend to use javascript for this purpose i think you need AJAX for this purpose.
    Using Ajax you can update a part of the page without Refresh or Submit.
    You can also integrate AJAX with STRUTS.
    If this is the case, i think i can help you.
    Post a reply with the details of what you want to perform on the onChange event.
     
    Unni krishnan, Jun 12, 2009 IP
  3. kunla

    kunla Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thankyou thankyou very much for reply...
    <logicresent name="StateList" scope="session">
    <td align="left"><font color="red"><b><b>*</b></b></font>&nbsp;<b>Select State</td>
    <td>
    <html:select property="selectedState" onChange="execute(this.form)">
    <htmlption value="-1">Select</htmlption>
    <htmlptions collection="StateList" property="label" labelProperty="value" />
    </html:select>
    </td>
    </tr>
    <tr></tr>
    </logicresent>
    Code (markup):
    After this there is button name "show".
    <html:submit property="method" value="Show" onClick="return(checks(this.form))"/>
    Code (markup):
    on clicking show button some text message is displayed on this same jsp below show button.(For this i am using hidden variable with value "False" then in checks i am seting its value to "True".on basis of hidden parameter value message is displayed.if this value is false then no message is displayed and if this value is true appropriate message is displayed.)
    But Now take the case when user change the statelist option then that message should be disappeared while changing the list,without clicking show button

    if still i am not clear,let me know.

    Waiting for reply..
     
    kunla, Jun 16, 2009 IP
  4. Unni krishnan

    Unni krishnan Peon

    Messages:
    237
    Likes Received:
    9
    Best Answers:
    2
    Trophy Points:
    0
    #4
    Hi kunla,

    From my understanding i think that you want to call check function again when you change the 'select'.
    If this is the case, u can add the 'checks(form)' function in onChange event.

    Or if you want to just hide the messasge on select change, u can add,
    in the onChange event.

    If i have misunderstood your query, or if you have further doubts, do reply.
     
    Unni krishnan, Jun 17, 2009 IP