Very urgent Image Selection

Ads
 

Very urgent Image Selection

View Answers

August 13, 2008 at 4:46 PM

Hi friend,

Your Problem in stateChanged() function opening "{" and closing braces "}" are not equal
No of opening braces "{" are 5 and closing braces "}" are 3

function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
var showdata = xmlHttp.responseText;
var strar = trim(showdata).split(":");
if(strar.length>0)
{
for(var i=1;i<=imgs.length;i++) {
if(imgid==img_id){
opener.document.getElementById("emp_id").value=strar[1];
opener.document.getElementById("emp_name").value=strar[0];
window.close();
}
}
}
-------------------------------

August 13, 2008 at 4:47 PM

<%@ page language="java" import="java.sql.*" %>
<html>
<head>
<script type="text/javascript">
var imageURL = "redar.jpg";
function changeImage(img_id) {

var imgs=document.getElementsByTagName('img');
for(var i=1;i<=imgs.length;i++) {
var imgid="myImage"+i;
if(imgid==img_id){
document.getElementById(img_id).src="greenar.gif";
}
else{
document.getElementById(imgid).src=imageURL;
}
}


}

function trim(stringToTrim) {
return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function validate()
{
var emp_value ="";
var count=0;
var imgs=document.getElementsByTagName('img');
for(var i=1;i<=imgs.length;i++) {
var imgid="myImage"+i;
var imgurl = document.getElementById(imgid).src;
var imgar = imgurl.split("/");
if(imgar[3]=="greenar.gif")
{
count++;
}
}
if(count==0)
{
alert("Please Select Employee Id");
return false;
}
return true;
}
function showEmp()
{
if(validate()){
var imgs=document.getElementsByTagName('img');
for(var i=1;i<=imgs.length;i++) {
var imgid="myImage"+i;
var emp_id = "eid"+i;
var imgurl = document.getElementById(imgid).src;
var imgar = imgurl.split("/");
if(imgar[3]=="greenar.gif")
{
var emp_value = document.getElementById(emp_id).value;
}
}
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)
}
}

function stateChanged(){
if (xmlHttp.readyState==4){
var showdata = xmlHttp.responseText;
var strar = trim(showdata).split(":");
if(strar.length>0){
for(var i=1;i<=imgs.length;i++) {
if(imgid==img_id){
opener.document.getElementById("emp_id").value=strar[1];
opener.document.getElementById("emp_name").value=strar[0];

window.close();
}
}
}
}
}

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>

August 13, 2008 at 4:48 PM

<body>
<form name="employee">
<br><br>
<table border="1" width="400px" align="center" bgcolor="#CDFFFF">
<tr><td align="center" colspan=2><b>Select Employee Id</b></td></tr>
<%
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);
con = DriverManager.getConnection(url+db,userName,password);
String query = "select * from Employee";
st = con.createStatement();
ResultSet rs = st.executeQuery(query);
%>
<%
int count=0;
while(rs.next())
{
count++;
%>
<tr><td align="center" width="50%">
<input type="hidden" value="<%=rs.getString(1)%>" id="eid<%=count%>">
<img src="redar.jpg" width="25px" height="25px" name="myImage" onclick="changeImage(this.id);" id="myImage<%=count%>" border="0">
<%=rs.getString(2)%></td>
<td width="50%"><%=rs.getString(3)%></td></tr>
<%
}
}
catch (Exception e) {
e.printStackTrace();
}
%>
<tr><td align="center" width="50%"><input type="button" value="Select" onclick="javascript:showEmp('Rose');"></td></tr>
</table>
</form>
</body>
</html>

Thanks

amar

Ads









Related Tutorials/Questions & Answers:
Very urgent Image Selection - JSP-Servlet
Very urgent Image Selection  Respected Sir/Madam, I am R.Ragavendran.. If you are telling that your coding works fine, then can u plz tell me or send me the output of the following code asap? var imageURL
very urgent
very urgent  ** how to integrate struts1.3 ,ejb3,mysql5.0 in jboss server with myeclipse IDE
Advertisements
image selection
image selection  hi my issue is : I have select dropdown list when I selected image it displays some default color having image I change the color... it redirect to error image page. can you tell how to solve this problem and where
its very urgent please help me
its very urgent please help me  how can i retrieve all images from ms access database and display in jsp pages
Ple help me its very urgent
Ple help me its very urgent  Hi.. I have one string 1)'2,3,4' i want do like this '2','3','4' ple help me very urgent
very urgent, want to submit my project on monday
very urgent, want to submit my project on monday  i have the code for connected combo-boxes(jsp). But the thing i want to know is, how to access the values selected in those combo-boxes, for storing in database. in the case
Please help me... its very urgent
Please help me... its very urgent  Please send me a java code to check whether INNODB is installed in mysql... If it is there, then we need to calculate the number of disks used by mysql
plz help -java project very urgent
plz help -java project very urgent  ? Ford furniture is a local furniture store in acts, and they as CS graduate students to implement a software system to generate various reports for them at the end of each month. You
Urgent
J2ME programming  Hi, J2ME programming - How to learn J2ME Programming very fast? Thank You
Selection Sort in Java
Selection sort in Java is used to sort the unsorted values in an array. In selection sorting algorithm, the minimum value in an array is swapped to the very first position in that array. In the next step the first value of array
urgent need
urgent need   Input a line. Count the number of words that start with a capital letter
Urgent requirement
Urgent requirement  I want to implement Autocompletion code for Jcombobox in swing can you please help me out from
highlight uitableviewcell on selection
the UITableViewCell on selection in my application.   UITableViewCell... highlight it or use the default selection for the cell in UITableView. Also you can disable the the stye by setting StyleNone to cell selection. But in case
ModuleNotFoundError: No module named 'urgent'
ModuleNotFoundError: No module named 'urgent'  Hi, My Python... 'urgent' How to remove the ModuleNotFoundError: No module named 'urgent'... to install padas library. You can install urgent python with following command
Selection based on other selection in jsp
Selection based on other selection in jsp  I am trying to create a jsp page. Where I am having a select list containing category name and for each... selection on same jsp page such that when someone select a category only the products
image
image  how to add the image in servlet code
Image
Image  how to insert image in xsl without using xml. the image was displayed in pdf..Please help me
Image
Image  how to insert image in xsl without using xml. the image was displayed in pdf..Please help me
Image
Image  how to insert image in xsl without using xml. the image was displayed in pdf..Please help me
JList Background Images..Urgent
image rather than background colors, how can i do it? Please help! my previous...); colorList.setVisibleRowCount(5); colorList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION
image
image   Dear every body please help me how to add and retrive image and video into oracle 11g using jsp
changing selection color of <button>
changing selection color of   dear all, i have loaded image in border less button tag when button is selected with tab key i get brown color rectangle around image. how do i change color of that rectangle from brown to white
insert multiple selection - Java
insert multiple selection - Java  how to insert multiple selection values from html into database using servlets
PLease reply its urgent
PLease reply its urgent   Write a java function that has the signature ΓΆβ?¬Ε?Public static int clock Inter sections(int hours, int minutes)ΓΆβ?¬Β...:minute:second format.   How's that urgent
ModuleNotFoundError: No module named 'selection'
ModuleNotFoundError: No module named 'selection'  Hi, My Python... 'selection' How to remove the ModuleNotFoundError: No module named 'selection' error? Thanks   Hi, In your python environment you
java linked list urgent !!!
java linked list urgent !!!  Q1. Generate 10 thousand random integers with values in the range between 1 to 100. Q2. Store each randomly generated number into a node and then attach the node to a linked list. The list must
java linked list urgent !!!
java linked list urgent !!!  Q1. Generate 10 thousand random integers with values in the range between 1 to 100. Q2. Store each randomly generated number into a node and then attach the node to a linked list. The list must
java linked list urgent!!!
java linked list urgent!!!  Q1. Generate 10 thousand random integers with values in the range between 1 to 100. Q2. Store each randomly generated number into a node and then attach the node to a linked list. The list must
java linked list urgent !!!
java linked list urgent !!!  Q1. Generate 10 thousand random integers with values in the range between 1 to 100. Q2. Store each randomly generated number into a node and then attach the node to a linked list. The list must
java linked list urgent !!!
java linked list urgent !!!  Q1. Generate 10 thousand random integers with values in the range between 1 to 100. Q2. Store each randomly generated number into a node and then attach the node to a linked list. The list must
java linked list urgent !!!
java linked list urgent !!!  Q1. Generate 10 thousand random integers with values in the range between 1 to 100. Q2. Store each randomly generated number into a node and then attach the node to a linked list. The list must

Ads