473,394 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Populate textbox fields when selections made in combo box

I have a jsp page

these are three formfields
itemsr : --it is a combobox
itemtype : --textfield
itemname : --textfield

to itemsr i have to populate from itemtable(database mysql) and by on change event when the option is changed in itemsr the corresponding itemtype and itemname from the itemtable should be displayed inside the textfield.
I want detail code of it
Nov 7 '07 #1
5 3608
acoder
16,027 Expert Mod 8TB
You can't expect someone to do all the work for you.

Post what code you have so far and we can suggest changes.

This has already been asked a number of times. You have two choices: either you want to load everything during page load and use arrays to store the data which is populated dynamically onchange, or you use AJAX to retrieve the data each time from the server.
Nov 7 '07 #2
this is my code
Expand|Select|Wrap|Line Numbers
  1. <body>
  2.             <html:form action="/pur">
  3.  
  4.             itemsr : <html:select  property="itemsr">
  5.                        <%try{
  6.             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  7.             Connection con=DriverManager.getConnection("jdbc:odbc:dsn2","root","root");
  8.             Statement st=con.createStatement();
  9.             String sq="select it_sr from bs_invent_items";
  10.  
  11.             ResultSet rs1= st.executeQuery(sq);
  12.  
  13.         while(rs1.next()){
  14.              String s1=rs1.getString(1);
  15.           out.println("<option>"+s1+"</option>");    
  16.           }
  17.            rs1.close();
  18.  
  19.            st.close();
  20.             con.close();
  21.  
  22.         }
  23.         catch(Exception e)
  24.         {
  25.             System.out.println(e);
  26.         }          
  27.              %>
  28.              </html:select><br/> 
  29.  
  30.  
  31.             itemtype : <html:text   title="itemtype" property="itemtype"/><html:errors property="itemtype"/><br/>
  32.             <SCRIPT type="text/javascript">
  33.             try{
  34.             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  35.             Connection con=DriverManager.getConnection("jdbc:odbc:dsn2","root","root");
  36.             Statement st=con.createStatement();
  37.  
  38.              HttpSession ses =request.getSession(true);
  39.   String idd = ses.getValue("id").toString();
  40.  
  41.             String sq="select it_type from bs_invent_items where it_sr='"+idd+"'";
  42.             System.out.println(sq);
  43.             ResultSet rs2= st.executeQuery(sq);
  44.  
  45.         while(rs2.next()){
  46.              String s1=rs2.getString(2);
  47.  
  48.           }
  49.  
  50.  
  51.            rs2.close();
  52.  
  53.            st.close();
  54.             con.close();
  55.  
  56.         }
  57.         catch(Exception e)
  58.         {
  59.             System.out.println(e);
  60.         }   
  61.         document.getElementById("itemtype").innerHTML = "+s1+"; 
  62.  
  63.             </SCRIPT>
  64.  
any i have populated itemsr from the database but by onchange event when the option of the itemsr is changed ,the field itemtype should get the value from database where itemsr is that selected option.

I have taken the value of item sr throug session.session is also notworking .How to put a sessionvariable in javascript
Nov 7 '07 #3
acoder
16,027 Expert Mod 8TB
Do you have any experience or are you willing to learn AJAX?
Nov 7 '07 #4
I am very new to ajax therefore i am unable to proceed further
Nov 12 '07 #5
acoder
16,027 Expert Mod 8TB
I am very new to ajax therefore i am unable to proceed further
Have a look at this simple example to get you started. If you have any problems, post again here and we'll try to solve it.
Nov 12 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Steve | last post by:
I have an unbound combobox in the form header of a continuous form. The selection in the combobox sets the where clause in a querydef which determines QryPFrmInventoryManagement. The following code...
0
by: Megan | last post by:
hi- i have a table, case, that i'm to normalize. for example, the table, case, has the following fields- caseid = primary key issue1 = number issue1desc = text issue2 = number
4
by: godber | last post by:
I need to populate text boxes for instance with employee information using their unique employee works number selected from a combo box. Can anyone help, I am told thru visual basic this can be...
1
by: commodityintelligence | last post by:
Greetings, I am merging a series of different tables into one query to export decision-making information. I have some architecture issues I need to ask for help on. I have no programming...
1
by: Peter | last post by:
Hi, I'm trying to create a form that shows table rows in a listbox. Several comboboxes expand the foreign key fields into text values from the parent tables, and there are also some textboxes...
2
by: Robertjb1 | last post by:
First Post - New member - I've searched the discussions available to no avail. I have, however, learned a few things in doing so. (Great Site -- Thanks) My issue is as follows: Access 2003/WinXP...
1
by: KMEscherich | last post by:
Using Access '97 Hi there, am wondering if someone can please help me with the following: I have a master table (T_INVESTIGATION) that contains the following fields as well as other fields. ...
4
by: whamo | last post by:
I have the need to populate a field based on the selection in a combo box. Starting out simple. (2) tables tbl_OSE_Info and tbl_Input; tbl_OSE_Info has three fields: Key, OSE_Name and OSE_Wt...
5
by: giandeo | last post by:
Hello Experts. Could you find a solution for this problem please! I have the following tables in Access Database Table Name: origin Fields Names: country, countrycode Table Name: make...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.