spbalu24
03-20-2007, 05:33 AM
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.
Hi this is very urgent for me. pls if any one know it give reply.
|
||||
sample program for change URL (combo box )without refreshing in java using ajaxspbalu24 03-20-2007, 05:33 AM 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. SSJ 03-20-2007, 06:03 AM 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 spbalu24 03-20-2007, 06:13 AM 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. SSJ 03-20-2007, 06:54 AM 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 SSJ 03-20-2007, 07:16 AM You can also done this without Ajax: Visit this: http://www.dynamicdrive.com/dynamicindex17/comboviewer.htm Hope this will help you... spbalu24 03-20-2007, 12:22 PM 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 + "¶m2=" + param2; } function ChangeURL3(FileName,param1,param2,param3){ location.href=FileName + ".jsp?param1=" + param1 + "¶m2=" + param2 + "¶m3=" + 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> 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=200');"><strong><a href="#" class="txtlink">HELP [?] </a> </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> </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> </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> </p> <p> </p> <p> </p> </body> </html> ------------------------------------------------------------------------ if possible help me spbalu24 03-20-2007, 12:49 PM 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. SSJ 03-20-2007, 12:50 PM 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. |
| |||
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum