Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Ajax how can add new line character into ajax response for java
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


bhoomika mishra
how can add new line character into ajax response for java
0 Answer(s)      a year and a month ago
Posted in : Ajax


i want to populated brand drop-down list and state drop-down list by changing on country drop-down list i mean according to country name there will be change in state names groups and brand name groups too... meaning that change in a single drop-down list changes into two dropdown list i hv donw this but i want both drop down will be in a new line how can i do this i m showing my codes here please help me

country.jsp

<%@page import="java.sql.*"%>
 <html>
      <head>  
      <script language="javascript" type="text/javascript">  
                          var xmlHttp  
                          var xmlHttp
                          function showState(str)
                              {
                                  xmlHttp=GetXmlHttpObject();
                                  if(xmlHttp==null)
                                      {
                                       alert ("Browser does not support HTTP Request")
                                       return
                                      }

                                  var url="State.jsp";
                                  url +="?count=" +str;

                                  xmlHttp.onreadystatechange = stateChange;
                                    xmlHttp.open("GET", url, true);
                                  xmlHttp.send(null);
                             }
                         function stateChange()
                                {   
                                  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
                                      {   
                                        document.getElementById("state").innerHTML=xmlHttp.responseText


                                      }   
                               }
                         function GetXmlHttpObject()
                             {
                                     var xmlHttp=null;
                                     try
                                     {
                                         xmlHttp=new XMLHttpRequest();
                                     }
                                     catch(e)
                                     {
                                         //Internet Explorer
                                         try
                                          {
                                                xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
                                          }
                                         catch (e)
                                          {
                                                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                                          }
                                    }
                                return xmlHttp;
                            }
            </script>  
      </head>  
      <body>  
     <form action="StateSub.jsp" >
      <select name='country' onchange="showState(this.value)">  
            <option value="none">Select Country</option>  
    <%
                 String id="";
                 String name= "";
                 Class.forName("com.mysql.jdbc.Driver").newInstance();  
                 Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/shoppingcart","root","rat");  
                 Statement stmt = con.createStatement();  
                 ResultSet rs = stmt.executeQuery("Select * from country");
                 while(rs.next())
                 {
                 id=rs.getString(1);
                 name=rs.getString(2);
     %>
                    <option value="<%=id%>"><%=name%></option>  
      <%
                }

     %>
      </select>  

      <br>  
      <div id='state'>  
      Enter state
      <select name='state' >  
      <option value='-1'></option>  
      </select>  

      Enter brand
       <select name='brand' >  
      <option value='-1'></option>  
      </select>  
      </div> 


      <input type="submit"/>

      </form>
      </body> 
      </html>


state.jsp

    <%@page import="java.sql.*"%>

 <%
String country=request.getParameter("count"); 
 System.out.println("State"+country);
 String buffer="Enter state<select name='state' ><option value='-1'>Select  state</option>";  
 try
  {
         String sid="";
         String snam="";
          String bid="";
         String bnam="";


         Class.forName("com.mysql.jdbc.Driver").newInstance();  
         Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/shoppingcart","root","rat");  
         Statement stmt = con.createStatement();  
         ResultSet rs = stmt.executeQuery("Select * from state where countryid='"+country+"' ");  
           while(rs.next())
           {
                sid=rs.getString(1);
                snam= rs.getString(3);
                buffer=buffer+"<option value='"+sid+"'>"+snam+"</option>";  
           }  
         buffer=buffer+"</select>"; 




 String buffer1="Enter brand<select name='brand' ><option value='-1'>Select  brand</option>";  


         Statement stmt1 = con.createStatement();  
         ResultSet rs1= stmt1.executeQuery("Select * from try where countryid='"+country+"' ");  
           while(rs1.next())
           {
                bid=rs1.getString(2);
                bnam= rs1.getString(1);
                buffer1=buffer1+"<option value='"+bid+"'>"+bnam+"</option>";  
           }  
         buffer1=buffer1+"</select>"; 
          response.getWriter().print(buffer+"::\\\\n"+buffer1);

  }
 catch(Exception e)
  {
     System.out.println(e);
  }

 %>


StateSub.jsp



    <%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">

    <title>My JSP 'StateSub.jsp' starting page</title>

    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->

  </head>

  <body>
  <%
  String s1=request.getParameter("country");
  String s2=request.getParameter("state");

  String s3=request.getParameter("brand");
  System.out.println(s1+" : "+s2+" : "+s3);
  out.println(s1+" : "+s2+" : "+s3);
   %>
  </body>
</html>

Advertisement
View Answers

Related Tutorials/Questions & Answers:
how can add new line character into ajax response for java
how can add new line character into ajax response for java   i want... down will be in a new line how can i do this i m showing my codes here please... { xmlHttp=new XMLHttpRequest
how can add new line character into ajax response for java
how can add new line character into ajax response for java   i want... down will be in a new line how can i do this i m showing my codes here please... { xmlHttp=new
Advertisements
How can i add a new count to this source code ? - Java Beginners
How can i add a new count to this source code ?  Hi everyone I...;ZHTYPE (Just Logical) Please tell me how can i see this output? Code... with this code is true but I want add ZHTYPE at the end of each line + XTSM/XTS please
How can i add a new count to this source code ? - Java Beginners
How can i add a new count to this source code ?  Hi everyone I...;ZHTYPE (Just Logical) Please tell me how can i see this output? Code... This output with this code is true but I want add ZHTYPE at the end of each line
add new package java
add new package java  How to add new package in Java
How to insert new line after every space in java
How to insert new line after every space in java  Hii Sir, I have a string with values 69 17 17 16 2 1 1 26 26 56 like this .Now as per my need i have to put all these values into new lines on getting space
How to write file text In New Line
text in new line in Java program. How to write the syntax for this with example... text in a new line. For finds examples or syntax please visit the link How to write file text in New line in Java
Java file new line
Java file new line In this section, you will learn how to write the text in new line of text file. Description of code: The package java.io.* has provide...(); } } Through the method newLine(), you can write the text to another line. Generated
How can i read a file from nth line onwards in java
How can i read a file from nth line onwards in java  Hi, I need to read a file content from its nth line onwards till end. How can i implement it in java. Regards, Chinnu
How can i draw a line using java swings
How can i draw a line using java swings  Sir my program contains different components i am using JFrame. I want to draw a straight line between components(Jtextfeilds, Jlabels).So could you help me for it. Thank You
How can i draw a line using java swings
How can i draw a line using java swings  Sir my program contains different components i am using JFrame. I want to draw a straight line between components(Jtextfeilds, Jlabels).So could you help me for it. Thank You
How to read big file line by line in java?
Learn how to write a program in java for reading big text file line by line In this tutorial I will explain you how you can read big file line by line... legacy data and add it to your new database system. Example discussed here
How can you add elements of two arrayLists in java?
How can you add elements of two arrayLists in java?  if you have an arrayList of tempArr = [hi, my, name, is, john] and another arrayList..., is d, john e] how do you go about
How to Delete a column and Add a new column to database
How to Delete a column and Add a new column to database   How to Delete a column and Add a new column to database   Hi, The following...- alter table [table name] add column [new column name] varchar (20); Thanks
How to write file by line in Java
in a new line. How to use Write To File By Line in Java programs...How to write file by line in Java  How to write file by line in Java   Hi, For Write to a file by line using java programming language we
character as command line arguments
character as command line arguments  public class testing { public static void main(String args[]) { char a; a=args[0]; System.out.println("character is:"+a); } } what will be the above program output
Java - How to read a string line per line
Java - How to read a string line per line  Java - How to read... to read the big String line per line? Is there any API available in Java... it line by line. This way you can reduce the memory usage of the application
How to add new class in Pkg using the feature of existing class - Java Beginners
How to add new class in Pkg using the feature of existing class   Hi Friends, I want to know , is it possible to add new class in a user Defined... access Variables or methods. Can i use them in another Class in the Same Pkg
Write Text To File In New Line.
Write Text To File In New Line. In this tutorial you will learn how to write text into file in a new line. When you are writing in a file you may be required to finish the line and want to write the other text in a new line
how can i add hibernate plugin to eclipse?
how can i add hibernate plugin to eclipse?  how can i add hibernate plugin to eclipse
AJAX Line
AJAX Line       AJAX Community with a blog, forum and tutorials Read full Description
simple ajax Request and Response code...
simple ajax Request and Response code...  var request=null; if (window.XMLHttpRequest) { request = new XMLHttpRequest(); } else if (window.ActiveXObject) { request = new ActiveXObject("Microsoft.XMLHTTP"); } if(request
how to add to numbers in java
how to add to numbers in java  how to add to numbers in java
how to print a new line after a certain number of prints
how to print a new line after a certain number of prints  How do I make this program print the inputs the user gives 5 per line? So in other words I want the program to print 5 input numbers per line. this is my code so far
how to add new column before two column in sql.
how to add new column before two column in sql.  how to add new... new fields dateOfJoining and address. Then using the given query, we can add the new columns to the existing table. Alter Table employee add (dateOfJoining date
how to add new column before two column in sql.
how to add new column before two column in sql.  how to add new... new fields dateOfJoining and address. Then using the given query, we can add the new columns to the existing table. Alter Table employee add (dateOfJoining date
how to add new column before two column in sql.
how to add new column before two column in sql.  how to add new... new fields dateOfJoining and address. Then using the given query, we can add the new columns to the existing table. Alter Table employee add (dateOfJoining date
how to add new column before two column in sql.
how to add new column before two column in sql.  how to add new... new fields dateOfJoining and address. Then using the given query, we can add the new columns to the existing table. Alter Table employee add (dateOfJoining date
How we can integrate ASP .net website to payment gateway using SOAP xml request and response using wsdl.
with wsdl format. As i'm new in development. How i can integrate our website...How we can integrate ASP .net website to payment gateway using SOAP xml request and response using wsdl.  We have a e-commerce website in ASP.net, c
How can i display the distance of a line drawing randomly?
How can i display the distance of a line drawing randomly?  How can i display the distance of a line drawing randomly
How can I execute a PHP script using command line?
How can I execute a PHP script using command line?  How can I execute a PHP script using command line
Advertisements
 

 

 

DMCA.com