|
|
| Program Urgent |
Expert:Ragavendran.R
Respected Sir/Madam, I am R.Ragavendran. I am in urgent need of the coding. My requirement is as follows: Beside Enter Employee ID text Box, There must be a small button. When user clicks this button, a small pop up window must be opened which comprises of Employee ID and Employee Name present in the database. When I click Employee ID present in the pop up box, The "Enter Employee ID" and "Enter Employee Name"text box must be filled automatically with the selected Employee ID and Name.
Its Very Urgent.. Please send me the coding asap..
Thanks/Regards, R.Ragavendran.. |
| Answers |
Hi friend,
<html> <head> <script type="text/javascript">
<!-- function popup(url, name, width, height){ settings= "toolbar=yes,location=yes,directories=yes,"+ "status=no,menubar=no,scrollbars=yes,"+ "resizable=yes,width="+width+",height="+height;
MyNewWindow=window.open("http://localhost:8080/examples/jsp/"+url,name,settings); } //--> </script> </head> <br><br> <center> <p> <body>
<input type="button" onclick="popup('sumcount.jsp', 'Win1', 600, 500)" value="Show New Window">
</body> </center></p> </html>
------------------------------------------------------
<%@ page import="java.sql.*" %>
<%
String emp_id = request.getParameter("emp_id").toString();
String data ="";
Connection con = null; String url = "jdbc:mysql://192.168.10.211:3306/"; String db = "amar"; String driver = "com.mysql.jdbc.Driver"; String userName ="amar"; String password="amar123";
int sumcount=0;
Statement st;
try {
Class.forName(driver).newInstance();
con = DriverManager.getConnection(url+db,userName,password);
String query = "select * from employee_details where eid='"+emp_id+"'";
st = con.createStatement();
ResultSet rs = st.executeQuery(query);
while(rs.next()){
data = ":" + rs.getString(2) + " " + rs.getString(3) +":"+ emp_id;
}
out.println(data);
}
catch (Exception e) {
e.printStackTrace();
}
%>
--------------------------------
|
<%@ page import="java.sql.*" %>
<html>
<head>
<style>
A:hover {text-decoration: none;
border: 0px;
font-size:14pt;
color: #2d2b2b; }
</style>
<link rel="stylesheet" type="text/css" href="datepicker.css"/>
<script type="text/javascript">
function showEmp(emp_value)
{
if(document.getElementById("emp_id").value!="-1")
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="getuser.jsp"
url=url+"?emp_id="+emp_value
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
else
{
alert("Please Select Employee Id");
}
}
function stateChanged(){
document.getElementById("ename").value ="";
document.getElementById("emp_id").value ="";
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
var showdata = xmlHttp.responseText;
var strar = showdata.split(":");
if(strar.length==1) {
document.getElementById("emp_id").focus();
alert("Please Select Employee Id");
document.getElementById("ename").value =" ";
document.getElementById("emp_id").value =" ";
}
else if(strar.length>1)
{
var strname = strar[1];
document.getElementById("emp_id").value= strar[2];
document.getElementById("ename").value= strar[1];
}
}
}
function GetXmlHttpObject(){
var xmlHttp=null;
try {
// Firefox, Opera 8.0+, Safari
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 name="employee">
<br><br>
<table border="0" width="400px" align="center" bgcolor="#CDFFFF">
<div id="mydiv"></div> <tr><td><b>Select Employee Id</b></td><td>
<select name="semp_id" onchange="showEmp(this.value);">
<option value="-1">Select</option>
<%
Connection con = null; String url = "jdbc:mysql://192.168.10.211:3306/"; String db = "amar"; String driver = "com.mysql.jdbc.Driver"; String userName ="amar"; String password="amar123";
int sumcount=0;
Statement st;
try {
Class.forName(driver).newInstance();
con = DriverManager.getConnection(url+db,userName,password);
String query = "select * from employee_details";
st = con.createStatement();
ResultSet rs = st.executeQuery(query);
%>
<%
while(rs.next()){
%>
<option value="<%=rs.getString(1)%>"><%=rs.getString(1)%></option>
<%
}
%>
<%
}
catch (Exception e) {
e.printStackTrace();
}
%>
</select>
</td></tr>
<tr><td ><b>Employee Id:</b></td> <td><input type="text" name="emp_id" id="emp_id" value=""></td></tr>
<tr><td><b>Employee Name:</b></td> <td><input type="text" name="emp_name" id="ename" value=""></td></tr>
</table>
</form>
<table border="0" width="100%" align="center">
<br>
<br>
</table>
</body>
</html>
------------------------------------------------------------------- Read for more information.
http://www.roseindia.net/jsp
Thanks. Amardeep
|
| More Questions |
|
|
Post Answers
Ask Question
Facing Programming Problem?
|
|
|
|
|