Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Mar 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    sample program for change URL (combo box )without refreshing in java using ajax

    sample program for change URL (combo box )without refreshing in java using ajax.

    Hi this is very urgent for me. pls if any one know it give reply.

  • #2
    SSJ
    SSJ is offline
    Regular Coder
    Join Date
    Mar 2007
    Posts
    230
    Thanks
    0
    Thanked 4 Times in 4 Posts
    If you want to change the URL then obviously your page has been refreshed and move to the next page...

    AM I getting wrong?
    Explain in details

  • #3
    New to the CF scene
    Join Date
    Mar 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by SSJ View Post
    If you want to change the URL then obviously your page has been refreshed and move to the next page...

    AM I getting wrong?
    Explain in details
    Hi,

    For example

    1 .If i chose for country(combobox) details will be displied below.

    2. If i chose for state(combobox) details will be displied below.

    if i choose for sate that time the hole page will be reloaded. So it will take time.

    I dont want to reload hole page.

    Using ajax it's possible .

    If u know ols send me.

  • #4
    SSJ
    SSJ is offline
    Regular Coder
    Join Date
    Mar 2007
    Posts
    230
    Thanks
    0
    Thanked 4 Times in 4 Posts
    Okay this is fine.
    It is possible through Ajax and very easy...
    Let me write a code for this...

    I will post once I done

  • #5
    SSJ
    SSJ is offline
    Regular Coder
    Join Date
    Mar 2007
    Posts
    230
    Thanks
    0
    Thanked 4 Times in 4 Posts
    You can also done this without Ajax:

    Visit this:
    http://www.dynamicdrive.com/dynamici...omboviewer.htm

    Hope this will help you...

  • #6
    New to the CF scene
    Join Date
    Mar 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi ,

    Here with i'm sending my coding.

    1.i will chose country,

    2.i will chose state

    3i will chose city

    Coding :
    --------

    <%@ include file="header.jsp" %>
    <%@ page import="org.pace.*,
    java.sql.Connection,
    java.sql.Statement,
    java.sql.ResultSet"%>



    <%

    String strcountrycode = "0";
    String strstatecode = "0";
    String strcitycode = "-1";

    String strstatename = "";
    String strcountryname = "";
    String strcityname = "";


    //checking the state code
    if (request.getParameter("param1") != null){
    strcountrycode=request.getParameter("param1").trim();
    }

    if (request.getParameter("param2") != null){
    strstatecode=request.getParameter("param2").trim();
    }

    if (request.getParameter("param3") != null){
    strcitycode=request.getParameter("param3").trim();
    }
    %>

    <%
    Connection con = MyConnection.getConnection();
    Statement stat = con.createStatement();
    ResultSet rs = null;
    ResultSet rs1 = null;
    ResultSet rs2 = null;

    /*int Rights=-1;
    String userCode = (String) session.getAttribute("UserCode");
    String Check="select profile_rights from profile_details where user_code="+userCode+" and profile_sub_code=4";

    try {

    rs2 = stat.executeQuery(Check);

    if(rs2.next()){
    Rights=rs2.getInt("profile_rights");
    }
    rs2.close();
    if(Rights == -1){
    response.sendRedirect("NotAuthorise.jsp");
    }

    }
    catch(Exception e) {
    e.printStackTrace(response.getWriter());
    }*/
    int sNo=0;



    %>


    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_preloadImages() { //v3.0
    var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }

    function MM_swapImgRestore() { //v3.0
    var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    }

    function MM_findObj(n, d) { //v4.01
    var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
    if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
    if(!x && d.getElementById) x=d.getElementById(n); return x;
    }

    function MM_swapImage() { //v3.0
    var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
    if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    }
    //-->
    </script>

    <script>
    //function for changing the url
    function ChangeURL1(FileName,param1){
    location.href=FileName + ".jsp?param1=" + param1;
    }
    function ChangeURL2(FileName,param1,param2){
    location.href=FileName + ".jsp?param1=" + param1 + "&param2=" + param2;
    }

    function ChangeURL3(FileName,param1,param2,param3){
    location.href=FileName + ".jsp?param1=" + param1 + "&param2=" + param2 + "&param3=" + param3;
    }
    </script>

    <form name="retailor" method=post>

    <table width="70%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td height="67" align="left" valign="top" bgcolor="#CFCFCF">
    <TABLE cellSpacing=1 cellPadding=0 width="100%"
    align=center border=0>
    <TBODY>
    <TR ><td>
    <table width=100% cellSpacing=0 cellPadding=0> <tr>
    <TD width=50% height=25 align=left class="Heading-Master"background="images/Bg_Master.jpg"><strong>&nbsp;&nbsp;RETAILOR
    VIEW </strong></TD>
    <TD width=50% height=25 align=right class="Heading-Master" background="images/Bg_Master.jpg" onclick="window.open('Help_Retailer.html','holder','width=800,height=400,scrollbars=1,top=182,left=2 00');"><strong><a href="#" class="txtlink">HELP [?] </a>&nbsp;&nbsp;
    </strong></TD>
    </TR></table></td> </tr>
    <TR bgcolor="#EBEBEB">
    <TD height=0 align="center" bgcolor="#cfcfcf" class="Heading-Master"><TABLE cellSpacing=1 cellPadding=0 width="100%"
    align=center border=0>
    <TBODY>
    <TR bgcolor="#EBEBEB">
    <TD height=25 colspan="4" align="center" class="Heading-Master"><strong></strong></TD>
    </TR>
    <TR bgcolor="#F5F5F5">
    <TD width="50%" height=25 align="right"> <span class="Heading-Master"><FONT
    color=#000000><strong>COUNTRY NAME</strong></FONT></span><FONT
    face="Verdana, Arial, Helvetica, sans-serif"
    color=#000000 size=1><STRONG>&nbsp;&nbsp;&nbsp;&nbsp;
    </STRONG></FONT></TD>
    <TD width="48%"
    height=25 colSpan=3 bgcolor="#F5F5F5"> <DIV align=left>
    <p class="field-text">
    <select name="countryname" class="Textbox" onChange="ChangeURL1('RetailorMasterView',document.retailor.countryname.options[document.retailor.countryname.selectedIndex].value);">


    <option value=''>Select Country</option>
    <%

    String countryname="";
    String countrycode="";
    String sql1="SELECT country_code,country_name FROM country " +
    " WHERE FLAG_STATUS <> 2 ";

    rs=stat.executeQuery(sql1);
    while(rs.next()) {
    countrycode = rs.getString("country_code");
    countryname = rs.getString("country_name");


    if(strcountrycode.equals(countrycode)) {
    strcountrycode=countrycode;
    strcountryname=countryname;
    %>
    <option value="<%=countrycode%>" selected><%=countrycode+"-"+countryname%></option>
    <%
    }
    else {
    %>
    <option value="<%=countrycode%>"><%=countrycode+"-"+countryname%></option>
    <%
    }

    }

    if(rs!=null)
    {
    rs.close();
    rs=null;
    }
    //Query for getting all the states
    %>
    </select>
    <FONT
    face="Verdana, Arial, Helvetica, sans-serif"
    color=#000000 size=1> </FONT></p>
    </DIV></TD>
    </TR>
    <%

    if (strcountrycode != "0")
    {
    %>
    <TR bgcolor="#F5F5F5">
    <TD height=25 align="right"><span class="Heading-Master"><FONT
    color=#000000><strong>STATE NAME</strong></FONT></span><FONT
    face="Verdana, Arial, Helvetica, sans-serif"
    color=#000000 size=1><STRONG>&nbsp;&nbsp;&nbsp;&nbsp;
    </STRONG></FONT></TD>
    <TD
    height=25 colSpan=3 bgcolor="#F5F5F5"><select name="statename" class="Textbox" onChange="ChangeURL2('RetailorMasterView',document.retailor.countryname.options[document.retailor.countryname.selectedIndex].value,document.retailor.statename.options[document.retailor.statename.selectedIndex].value);">

    <option value=''>Select State</option>
    <%

    String statename="";
    String statecode="";
    String sql2="SELECT state_code ,state_name FROM state where country_code='"+strcountrycode+"' " +
    " and FLAG_STATUS <> 2 ";

    rs=stat.executeQuery(sql2);
    while(rs.next()) {
    statecode = rs.getString("state_code");
    statename = rs.getString("state_name");


    if(strstatecode.equals(statecode)) {
    strstatecode=statecode;
    strstatename=statename;
    %>
    <option value="<%=statecode%>" selected><%=statecode+"-"+statename%></option>
    <%
    }
    else {
    %>
    <option value="<%=statecode%>"><%=statecode+"-"+statename%></option>
    <%
    }

    }

    if(rs!=null)
    {
    rs.close();
    rs=null;
    }
    //Query for getting all the states
    %>
    </select></TD>
    </TR>
    <% }
    }
    if(stat!=null)
    {
    stat.close();
    stat=null;
    }if(con!=null)
    {
    con.close();
    con=null;
    }
    %>
    </table>

    </DIV></TD>
    </TR>

    </TBODY>
    </TABLE></td>
    </tr>
    </table>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    </body>
    </html>

    ------------------------------------------------------------------------

    if possible help me

  • #7
    New to the CF scene
    Join Date
    Mar 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by SSJ View Post
    Okay this is fine.
    It is possible through Ajax and very easy...
    Let me write a code for this...

    I will post once I done
    Hi,



    For example

    1 .If i chose for country(combobox) details will be displied next combobox

    2. If i chose for state(combobox) details will be displied below next combobox.

    if it's possible reply me.

  • #8
    SSJ
    SSJ is offline
    Regular Coder
    Join Date
    Mar 2007
    Posts
    230
    Thanks
    0
    Thanked 4 Times in 4 Posts
    Sorry I am not familiar with JSP.
    I can give you suggestions regarding how can you implement this one...

    Make a div for 2nd combo on this page.
    Put your 2nd combo-box code on another page and send a ajax request on that page then write the response.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •