select one item name throug combo box than other combobox show item price

select one item name throug combo box than other combobox show item price

i have one table in database item master..if i select one item name through combo box than other combobox show item price only select item name... how i can implement through jsp in a single jsp page.

View Answers

April 3, 2012 at 1:11 PM

We have used table item having fields itemId, itemName, itemPrice.

1)items.jsp:

<%@page import="java.sql.*"%>
<%@page import="java.util.*"%>
<html>
<head>
<script language="javascript" type="text/javascript">
var xmlHttp;
function showState(str){
if (typeof XMLHttpRequest != "undefined"){
xmlHttp= new XMLHttpRequest();
}
else if (window.ActiveXObject){
xmlHttp= new ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlHttp==null){
alert ("Browser does not support XMLHTTP Request")
return
}
var url= "price.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("item").innerHTML=xmlHttp.responseText
}
}
</script>
</head>
<body>
<select name='country' onchange="showState(this.value)">
<option value="none">Select</option>
<%
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/register","root","root";);
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("Select * from item");
while(rs.next()){
%>
<option value="<%=rs.getString("itemName")%>"><%=rs.getString("itemName")%></option>
<%
}
%>
</select>
<br>
<div id='item'>
<select name='item' >
<option value='-1'></option>
</select>
</div>
</body>
</html>

2)price.jsp:

<%@page language="java" import ="java.sql.*" %>
<%
String itemname=request.getParameter("count");
String buffer="<select name='state'><option value='-1'>Select</option>";
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/register","root","root";);
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("Select * from item where itemName='"+itemname+"' ");
while(rs.next()){
buffer=buffer+"<option value='"+rs.getString("itemPrice")+"'>"+rs.getString("itemPrice")+"</option>";
}
buffer=buffer+"</select>";
response.getWriter().println(buffer);
%>

August 23, 2012 at 3:58 PM

its help ful to my code thank you very much

Ads









Related Tutorials/Questions & Answers:
select one item name throug combo box than other combobox show item price
select one item name throug combo box than other combobox show item price  i have one table in database item master..if i select one item name through combo box than other combobox show item price only select item name... how i
Not Able to select an Item in Spark Combo Box control (Adobe Flex Object) using QTP
Not Able to select an Item in Spark Combo Box control (Adobe Flex Object) using... Flex controls. But i am not able to select any item from Spark Combo Box. I tied using .Open (Its not opening the drop down list) , also i tried using Select
Advertisements
item lookup
item lookup  I need to create a lookup box in a grid that searches and filters at the same time. Upon selection the item with its price should be displayed. The control would then position below the first selection, so
nested selected tag ihave display selected item
nested selected tag ihave display selected item   i have two combo boxes combo1 combo1 in first combo box i taken as follows select name="combo1...="2">UK etc in other combo box display all states relate first combo box
how to select second combobox value .
how to select second combobox value .  I requirement is , i have two combo box, i am selected first combo box value then automatically second combo box value show ,But this both combo box value i retrieves in database. please
how to get selected name from combo box
how to get selected name from combo box   i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz
how to get selected name from combo box
how to get selected name from combo box   i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz answer
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz answer
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz answer
How can i select a particular item in jpopup menu through java programs
How can i select a particular item in jpopup menu through java programs ... menu item in it. assume that the user pressing down key 3 times. I need to show... a perticular menu item in jpopup menu to be selected. I created a gui where it has
Item Events in Java
of the combo box are as follows : Red, Green, Blue. If you select an item from the combo box then the message with the item name will be displayed in the text area... events in java. This demonstrates that the event generated when you select an item
Use of Select Box to show the data from database
select any other item from select box then it will reflect to the text box as well... Use of Select Box to show the data from database       Example program using Select Box to show retrieved data
How to show autocomplete textbox values on combo box option selection using database?
How to show autocomplete textbox values on combo box option selection using database?  When I select option(i.e First Year) then it will show list of student names in auto-complete text box
How to obtain the selected data item from a list box when listbox contains objects wrapped under Arraylist?
want to copy the selected item(one at a time) from the list box to the text box. I...How to obtain the selected data item from a list box when listbox contains objects wrapped under Arraylist?  I have a jsp page containing a list box
How to change object item to integer item
How to change object item to integer item  How to change objectitem to integer item?thankyou
return item in jquery
return item in jquery  How to return items/variables in JQuery?   See the code below to find out how to return an Item in Jquery: function findItem() { var item; while(if_item_not_found) { // search
delete an item from database
delete an item from database  how to delete an item from the database using jsp
Combo Box operation in Java Swing
if the combo box has one item at least otherwise a message box will display... of the item of the combo box at the specified position. This specification of position the item in the combo box is held by the getItemAt() method
populating one dropdown box depending on the value of other using jsp
populating one dropdown box depending on the value of other using jsp  HI i have scenario i need to populating one dropdown box depending... in dropdown box one after the other CREATE TABLE CITY_MASTER( CITYID BIGINT
ModuleNotFoundError: No module named 'item'
ModuleNotFoundError: No module named 'item'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'item' How to remove the ModuleNotFoundError: No module named 'item' error
Item renderer in flex
Item renderer in flex  Hi...... please tell me about How to create item renderers in flex? give an example for that Thanks
Combo box In Java
an item from the item list. You can never select more than one item from a combo.... Combo box allow you to select one of the option which appear at the user... item from the existing combo box mode. JComboBox(Object[]  ob) : Create
Helps with combo box and frame
Helps with combo box and frame  Hi i have a combobox and when i click on add button another frame pop up with text field(name ,address etc... on the second window and click confirm i would have the information on the combo box. i
Java JComboBox Get Selected Item Value
example into which I shall get the combo box selected item value and stored... will be displayed as follows : 3. When you will select any of the list item it will show... Source Name, give the DSN name and click on Select button When you will click
navigation item back button
navigation item back button  I wants to add a navigationBar on the top of my UIWebView also a navigation item "back button". can anyone please explain how the back and refresh button works
How to pass the value of Selected Value of combo box into sql ??
How to pass the value of Selected Value of combo box into sql ??  My SQL Database Name is MHS, user=root, password=admin,table name is sub_comb(regno,sname,sgen). Now i want to select one "regno" from Combobox and then after
combo box
combo box  Hi, [_|] dropdown box... a screen like this using jsp-servlet(or DAO,DTO),in that drop down box i should get... to that user in left list.when we select module from left list and click INCLUDE button
highlight menu item html
highlight menu item html  highlight menu item in html or CSS   <body id="index"> <div id="menu"> <ul> <li class="index" ><a href="index.html">Index page</a></li> <
Linking JMenu Item with a JPane in Netbeans
Linking JMenu Item with a JPane in Netbeans  How do you link a Jpane window to a JMenu Item in Java Netbeans
two linked combobox
two linked combobox  give jsp example of two combo box when i select state in one combobox in second combo box cities will display according to state which i select

Ads