Originally posted by mou haj:
Hello mou
this is the code that i originally have with some modifications done..but it's still not working
<html>
<head>
<title>Feedback Form</title>
<script>
function isBlank(s){
var len=s.length
var i
for(i=0;i<len;i++){
if(s.charAt(i)!=" ")
return false
}
return true
}
function validate(fieldName,fieldValue){
if(isBlank(fieldValue)){
alert(fieldName+" cannot be blank !")
document.feedbackform.ecnumber.focus()
return false
}
return true
}
function fieldValidate(fieldName,fieldValue){
var checkOk="1234567890";
var checkStr=fieldValue;
if(checkStr.length>0)
{
var allValid = true;
for (i = 0;i<checkStr.length;i++)
{
ch = checkStr.charAt(i);
for (j = 0;j < checkOk.length;j++)
if (ch == checkOk.charAt(j))
break;
if (j == checkOk.length)
{
allValid = false;
break;
}
}
if (!allValid)
{
alert(fieldName+" is not valid!");
document.feedbackform.ecnumber.focus()
return false;
}
}
}
function strValidate(fieldName,fieldValue)
{
if(fieldValue.length<9){
alert(fieldName+"must contain 9 characters !")
document.feedbackform.ecnumber.focus()
return false;
}
return true
}
function validateECNumber(){
if(validate("The ECNumber field",document.feedbackform.ecnumber.value) | | fieldValidate("The ECNumber field",document.feedbackform.ecnumber.value) | | strValidate("The ECNumber field",document.feedbackform.ecnumber.value)){
document.forms[0].action="userfeedback_form.jsp";
document.forms[0].submit()
boolean validate=true
}
}
</script>
</head>
<body background="BACKGROUND1.jpg" style="font-family: Verdana; font-size: 10pt" onLoad="document.feedbackform.ecnumber.focus()">
<br><p>
<table border="0" width="780" cellspacing="0" cellpadding="0">
<tr>
<td width="100%">
<table border="0" width="100%" height="241">
<tr>
<td width="100%" background="HEADER1.jpg" height="77"> </td>
</tr>
<tr>
<td width="100%" height="152">
<p align="center"><b><font color="#000080">Feedback Form</font></b></p>
<table border="0" width="100%">
<tr>
<form name="feedbackform" onSubmit="return validateECNumber()" method="post">
<td width="32%"><font color="#000080"><b><font size="2">Please Enter your EC Number</font>
</b>
</font>
</td>
<td width="68%"><font color="#000080">
<input type="text" name="ecnumber" size="9" maxlength="9" onBlur="validateECNumber()">
</form>
<%
boolean validate=false;
%>
<%@ page import="java.sql.*" %>
<%
if(validate){
String empecnumber=request.getParameter("ecnmuber");
String driver="sun.jdbc.odbc.JdbcOdbcDriver";
String protocol = "jdbc dbc:employeedatabase";
String query = "SELECT * FROM employeedatatable where ecnumber like 'empecnumber' " ;
Connection connection;
Statement statement;
ResultSet rs;
Class.forName(driver);
connection = DriverManager.getConnection(protocol);
statement = connection.createStatement();
rs = statement.executeQuery(query);
while(rs.next()){
String name = rs.getString(1);
String phone = rs.getString(2);
String location = rs.getString(3);
out.println(phone);
}
}
%> </td>
</tr>
<tr>
<td width="46%"><font size="2" color="#000080"><b>Name:
<input type="text" name="ename" size="30" maxlength="9" value="name"></b></font></td>
<td width="54%"><font size="2" color="#000080"><b>Location :
<input type="text" name="elocation" size="6" maxlength="9"></b></font></td>
</tr>
<tr>
<td width="46%"><font size="2" color="#000080"><b>Phone:
<input type="text" name="ephone" size="6" maxlength="9"></b></font></td>
<td width="54%"> </td>
</tr>
<tr>
<td width="100%" colspan="2">
<p align="center"><font size="2" color="#000080"><b>We would like to
head from you, Please Enter your suggestions here</b></font></p>
</td>
</tr>
<tr>
<td width="100%" colspan="2">
<p align="center"><b><font color="#000080"><font size="2">Comments
and Suggestions:</font> </font></b><br>
<br>
<textarea rows="8" name="ecomments" cols="50"></textarea>
<p align="center"> </p>
<p align="center"><input type="submit" value="Submit"> <input type="reset" value="Reset" name="reset"></p>
<p align="center"> </p>
<p> </p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
please suggest the changes that are necessary
Yogen Vadnere
Originally posted by Yogen Vadnere:
Hello Yogen,
thanx a lot for your script , it did work and i am using it in one of my projects....and finally relieved me of the stress i was undergiong for 3 days.
thanx,
Whatever. Here's a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|