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



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

Have Programming Question? Ask it here!
 
 
 


bhoomika mishra
how can add new line character into ajax response for java
0 Answer(s)      11 months 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> <br />
      <script language="javascript" type="text/javascript"> <br />
                          var xmlHttp <br />
                          var xmlHttp
                          function showState(str)
                              {
                                  xmlHttp=GetXmlHttpObject();
                                  if(xmlHttp==null)
                                      {
                                       alert ("Browser does not support HTTP Request")
                                       return
                                      }</p>

                             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;
                        }
        &lt;/script&gt;  
  &lt;/head&gt;  
  &lt;body&gt;  
 &lt;form action="StateSub.jsp" &gt;
  &lt;select name='country' onchange="showState(this.value)"&gt;  
        &lt;option value="none"&gt;Select Country&lt;/option&gt;  
&lt;%
             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);
 %&gt;
                &lt;option value="&lt;%=id%&gt;"&gt;&lt;%=name%&gt;&lt;/option&gt;  
  &lt;%
            }

 %&gt;
  &lt;/select&gt;  

  &lt;br&gt;  
  &lt;div id='state'&gt;  
  Enter state
  &lt;select name='state' &gt;  
  &lt;option value='-1'&gt;&lt;/option&gt;  
  &lt;/select&gt;  

  Enter brand
   &lt;select name='brand' &gt;  
  &lt;option value='-1'&gt;&lt;/option&gt;  
  &lt;/select&gt;  
  &lt;/div&gt; 


  &lt;input type="submit"/&gt;

  &lt;/form&gt;
  &lt;/body&gt; 
  &lt;/html&gt;

state.jsp

&lt;%@page import="java.sql.*"%&gt;

 &lt;%
String country=request.getParameter("count"); 
 System.out.println("State"+country);
 String buffer="Enter state<select name='state' ><option value='-1'>Select  state</option>"; <br />
 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+"&lt;option value='"+sid+"'&gt;"+snam+"&lt;/option&gt;";  
       }  
     buffer=buffer+"&lt;/select&gt;";

 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+"&lt;option value='"+bid+"'&gt;"+bnam+"&lt;/option&gt;";  
       }  
     buffer1=buffer1+"&lt;/select&gt;"; 
      response.getWriter().print(buffer+"::\\\\n"+buffer1);

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

%>

StateSub.jsp

&lt;%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%&gt;
&lt;%
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="&lt;%=basePath%>">

&lt;title&gt;My JSP 'StateSub.jsp' starting page&lt;/title&gt;

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

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 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
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
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
AJAX Line
AJAX Line       AJAX Community with a blog, forum and tutorials Read full Description
how can i add hibernate plugin to eclipse?
how can i add hibernate plugin to eclipse?  how can i add hibernate plugin to eclipse
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 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 to numbers in java
how to add to numbers in java  how to add to numbers in java
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
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 can i draw line between two panel contaning circle and line between their center?
how can i draw line between two panel contaning circle and line between their center?   how can i draw line between two panel contaning circle and line between their center
How to get the unicode of japanese character input in java
How to get the unicode of japanese character input in java  Good Evening sir/madam; I am trying to create an application in java which needs to show the japanese character on frame and need to get the japanese string from
How to read a large text file line by line in java?
How to read a large text file line by line in java?  I have been... you kind advice and let's know how to read a large text file line by line in java... of the application and the memory available for the Java program. For Java program max
Java Read File Line by Line - Java Tutorial
into byte array in Java Developers can also add the further processing... line by line in Java programming language. This video tutorial will show you how... tutorial that explains you how to read a text file in Java one line at a time
how i can add an horizontal scrollbar at my PdfAnnotation ? - JSP-Servlet
how i can add an horizontal scrollbar at my PdfAnnotation ?  How to add the an horizontal scrollbar at my PdfAnnotation ? for example document d=new document(0. document.open
How Can I get ArrayList of Data from jsp with ajax request
How Can I get ArrayList of Data from jsp with ajax request  Hi, I retereved 5 Employee Record of Data from Struts Action class to jsp with ajax response. But I don't how how can reterve this dynamic 5 employee records
How to add google page in my webpage using jquery ajax.
How to add google page in my webpage using jquery ajax.  Hi, I... not open on my browser. how google page will load using ajax. thanks...://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script type="text
How to Read file line by line in Java program
by line in Java. But there are various ways that can help read a larger file... having less amount of memory. In the example of Java Read line by line below... line. The other methods that can be used are: read() method of BufferedReader
BufferedReader in Java
Line by line. It also reads text from a character-input stream. A programmer can change the buffer size or can use default size. BufferedReader class in Java is also used to read the data in buffer. Here we will show how to read line
Java Servlet : Http Response Headers
Java Servlet : Http Response Headers In this tutorial, you will learn how to Http Response Headers works in java servlet. Http Response Headers : Web... content. You can use HTTP response headers to specify cookies, to instruct
Java Read File Line By Line, Video Tutorial of Java Read File Line By Line
this feature of Java. Following is the video tutorial that shows you how you can write... file in Java line by line The java.util.Scanner class can also be used... a program in Java programming language to read a text file line by line. The "
how to add database in Java Applet
how to add database in Java Applet  hi every java master or Java Professional my name is vincent i'm java beginners hope u all can ,tech me how to add database in Java Applet below this code is my applet source code . thank
How to add dynamic table in java
How to add dynamic table in java  How to add dynamic table in java... JTableDatabase { public static void main(String[] args) { Vector columnNames = new Vector(); Vector data = new Vector(); JPanel p=new JPanel(); try { Class.forName
How To Read Integer From Command Line In Java
How To Read Integer From Command Line In Java In this section we will discuss about how an integer can be read through the command line. In Java all... in Java. In Java their are various wrapper classes of primitive data types
How to convert entity character to html character
How to convert entity character to html character  Please help me to "convert entity character to html character" in java. If possible please provide source code which take String as input and return as String
How to delete line starting with a letter in java Regex?
How to delete line starting with a letter in java Regex?  Hi, i 'm trying to code with regex and java. i want to know how it's possible to delete lines which starts with a letter like G or g in a text. i tried
xCode 4 add new framework
xCode 4 add new framework  Hi, How to add new framework in Xcode 4 based application? Thanks
how can i use ajax and jquery in netbeans ide
how can i use ajax and jquery in netbeans ide  i am using .net here we hav to download ajax controls and if i use netbeans ide and uses ajax control so from where i can get these controls.also i want to know which struct book i
How to delete a character from a file in java - Java Beginners
How to delete a character from a file in java  I'm not gettting how to remove a character from a file in java....could any one help me out??  Hi friend, To remove a character in what way : At a specified position
How to convert entity character to html character
How to convert entity character to html character  How to convert entity character to html character
 

 

 

DMCA.com