473,513 Members | 2,490 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

change the textbox value depending on selection made in dropdown

17 New Member
In dropdown i am retriving value from the backend.
For eg: in the dropdown list the value selected are employee id..then i want to disply the emp name,job etc in the textbox. If i select a optino in dropdown menu then that id name etc shuld come in the textbox without refreshing the page...
plz any help.......


<%@ page import="java.util.*" %>
<%@ page language="java" %>
<%@ page import="java.sql.*" %>
<HTML>
<head>


<H1>FAQ</H1>
<% String two; %>
<script type="text/javascript">
function myfun()
{
var category=document.getElementById("category");
document.getElementById("opt").value=category.opti ons[category.selectedIndex].text;

form1.submit();


}
function refresh()
{

var indexOfcombobox = document.form1.opt1.value;
sel = document.form1.category;
for (i=0; i<document.form1.category.options.length; i++) {
if (sel.options[i].text ==indexOfcombobox ) {
document.form1.category.selectedIndex = i;
}
}
}


</script>
</head>
<FORM name="form1" method=post action="">
<body onload="refresh()">

<input type=hidden name=opt>
<%
String nameselection = null;
String one=null;
ResultSet rs1;
Statement statement,st1;
Connection conn;
%>
<div>
<SELECT NAME="Category" id="Category" value="opt" onChange="myfun()">
<%

out.println("Hhh"+one);
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn=DriverManager.getConnection("jdbc:odbc:man"," scott","tiger");

statement= conn.createStatement();
ResultSet rs = statement.executeQuery("SELECT DISTinCT name FROM LOGIN" );
%>
<OPTION VALUE='nochoice'>Please choose a category</OPTION>";
<%while(rs.next()) {
nameselection = rs.getString("name");%>
<OPTION value ="optcategory"><%out.println(nameselection);%>
</OPTION>
<% } %>
</SELECT> </div>
<%
String sql1 = "SELECT * from login where name='"+request.getParameter("opt")+"' ";
rs1=statement.executeQuery(sql1);
%>

<% while (rs1.next())
{

String val1=rs1.getString("name");
String val2=rs1.getString("pwd");

out.println ("<input type=text name=opt1 value='" + val1 + "'>");
out.println ("<input type=text name=opt2 value='" + val2 + "'>");
}%>

</FORM> </body>
</HTML>
Am getting the selected values but the choice box is also refreshing and coming to the default value...plz any help
Mar 18 '08 #1
2 3080
hussain123
28 New Member
Put your selected option in a session variable and when the page reloads check for it's value and accordingly make your options selected.
Mar 18 '08 #2
manishamca
17 New Member
thanx but can u give me the example .plz....



Put your selected option in a session variable and when the page reloads check for it's value and accordingly make your options selected.
Mar 18 '08 #3

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

Similar topics

6
2701
by: A P | last post by:
Hi! I have seen some techniques like this on the web. Currently, I'm using Combo box which values came from database table. One disadvantage is when the combo box have lots of values, users are...
10
2275
by: JL | last post by:
Does anyone have any ideas on this please? I don't know how to evaluate the no-blank selections against each other from a form as follows: . I have a form with 6 dropdown fields, each...
4
20953
by: JohnSouth104 | last post by:
Hi I want to warn the user that changing the selected item in a pull-down will clear some data he has already entered in a file download box. I've tried using confirm() to return true or false...
2
2334
by: Luis Esteban Valencia | last post by:
Hello I have a datagrid with a dropdownlist that has the products, another column has the price of the product and when the user changes the product it also must change the price how can I achieve...
3
4980
by: Tom | last post by:
I am writing a Visual basic .Net database application. There are many forms that first let you select and look at a DB record and then when you click a "modify" button you are allowed to change...
0
1902
by: CCLeasing | last post by:
Hello, I have searched google but can not find a straight forward answer to my problem. Hopefuly someone will be kind enough to offer their expertise. Please forgive if this seems a bit convoluted...
11
4450
by: harold.gimenez | last post by:
Hi group, I am trying to change the selection of an ASP Dropdownlist just like "Orange" is selected here: http://www.w3schools.com/js/tryit.asp?filename=try_dom_option_selected The...
1
2269
by: martin DH | last post by:
Hello, I have a unique situation, I believe. I have a form with unbound textboxes (frmEditReport) - most populate from a search query but one unbound textbox, txt_ReturnInfo, populates based on a...
0
7260
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
7537
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...
0
5685
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4746
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3233
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1594
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
799
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
456
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.