Hi,
I'm new bee to JSP.I'm newly joined in company they want to finish this today please help me.
I need to check form field contains existing data(want to check database) are not.
if that field contain existing data it wants give alert..,
In database i set projectcode as Unique.if 1st user giving projectcode as 1 it wants to store.
if 2nd user giving the same projectcode it want's to throw alert msg..,
But i need to learn step by Step.
So i created Form with one Field(ProjectCode).In database i set ProjectCode as unique.
my code coming below
javaScript in Form
function loadContent(formj)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Your browser does not support Ajax HTTP");
return;
}
var stateValue = formj.dil_ProjectCode.value;
alert(stateValue);
var url="Code.jsp";
url=url+"?dil_ProjectCode="+stateValue;
alert(url);
xmlhttp.onreadystatechange=getOutput;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function getOutput()
{
if (xmlhttp.readyState==4)
{
var result = xmlhttp.responseText;
alert(result);
}
}
function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
{
return new XMLHttpRequest();
}
if (window.ActiveXObject)
{
return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}
form field code
<input type="text" name="dil_ProjectCode" id="dil_ProjectCode" >
code.jsp(it is reffered in javascript)
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:sid","username","password");
stateId = request.getParameter("dil_ProjectCode");
String query = "select projectcode from jerald where projectcode ="+stateId+"";
stmt = con.prepareStatement(query);
rs = stmt.executeQuery();
String Project = null;
while(rs.next())
{
Project = ""+ rs.getString(1);
}
out.print(Project);
}
in this code i want to get value of project in alert msg.
but i'm not retrieving any data in alert msg showing blank window please help me...