Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Harshu
SQL
0 Answer(s)      4 years and 10 months ago
Posted in : SQL


<%@ page language="java" import="java.io.*,java.lang.* ,java.sql.*,java.util.*,java.text.*,java.text.SimpleDateFormat" %>


<%

Connection con=null;
ResultSet rs=null;
Statement stmt=null;
int No=0,id=0,i=0;

String strDateNew=null;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:Advdsn");
stmt=con.createStatement();
java.util.Date now = new java.util.Date();
String DATE_FORMAT = "dd-MM-yyyy hh:mm:ss";
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
strDateNew = sdf.format(now) ;

ResultSet no=stmt.executeQuery("select OrderNo from OrderTab");

while(no.next())
{
int Ono=no.getInt("OrderNo");
No=Ono+1;
}


}



catch(SQLException se)
{out.println("Database error="+se.getMessage());
}

catch(Exception e)
{out.println("Error="+e.getMessage());
}


%>


<HTML>
<HEAD>
<TITLE> Place Order </TITLE>
<script type="text/javascript">
function checkName(text)
{
if(isNaN(text)){ return 1;}
else{alert("Invalid Name! The only charachters accepted are A - Z and a - z");return 0;}
}
function checkPhoneNo(num){
if(isNaN(num)){alert("Invalid Phone Number. The only characters permitted are 0 to 9"); return 0;}
else{return 1;}
}

function Validate()
{
var name=document.form.Name;
var phone=document.form.PhoneNo;
var email=document.form.Email;
var desig=document.form.Desig;
var qualify=document.form.Qualify;

if(document.form.OrderNo.value=="")
{ alert("Please enter valid OrderNo");
return false;
}
if(name.value=="")
{ alert("Please enter valid Client's Name");
return false;

}

if (checkName(name.value)==false){
name.value="";
name.focus();
return false;
}
if(document.form.Address.value=="")
{ alert("Please enter valid Client's Address");
return false;
}

if(desig.value=="")
{ alert("Please enter valid Designation");
return false;

}
if(qualify.value=="")
{ alert("Please enter valid Qualification");
return false;

}
if(email.value=="")
{ alert("Please enter valid Email Id");
return false;
}
apos=email.value.indexOf("@")
dotpos=email.value.lastIndexOf(".")
if (apos<1 || dotpos-apos<2)
{
alert("Invalid Email Id")
email.value=="";
email.focus();
return false;
}

if((phone.value=="")||(phone.value==null))
{ alert("Please enter valid PhoneNo");phone.focus();
return false;
}
if (checkPhoneNo(phone.value)==false){
phone.value="";
phone.focus();
return false;
}
if ((phone.value.length==8)||(phone.value.length==10)){
return true;
}
else{
alert("Phone Number must be of 8 numbers or 10 numbers");
return false;
}
return true;
}

function go()
{response.sendRedirect("PlaceAd.jsp");}

</script>

</HEAD>

<BODY BGCOLOR="lightblue">
<marquee behavior="alternate" scrollamount=5 scrolldelay=10>
<h1><font size=4 face="Stroustroup" color="#993355">Advertisement Management System</h1></font></marquee><br>
<p align=center> Order Details</p>
<hr color="green">
<img src="images\working with agency.jpg" alt"ORDERS" align="left"></img>
<% String uids=request.getParameter("uid"); %>
<form method="post" onsubmit="return Validate();" name="form" action="http://localhost:8080/ProjectAd/Orders.jsp">
<center>
<table>
<tr><td>Order No:</td><td><input type="text" id="OrderNo" name="OrderNo" size=25 value="<%=No%>" readonly onsubmit="go()";></td></tr>
<tr><td>Order Date:</td><td><input type=text name="Date" value="<%=strDateNew%>" readonly></td></tr>

<tr><td>Name:</td><td><select name="Name" size=1 >
<%
ResultSet nm=stmt.executeQuery("Select Name from Register ");
while(nm.next())
{
String usernm=nm.getString("Name");
%>
<option value="<%=usernm %>">
<%

out.println(usernm); %>
</option>
<%}%>
</select></td></tr>

<%String nms=request.getParameter("Name"); %>
<tr><td>User id:</td><td><select name="id" size=1>
<%
ResultSet userid=stmt.executeQuery("select UserId from Register where Name= request.getParameter('Name')");
while(userid.next())
{
int uid=userid.getInt("UserId");
%>
<option value="<%=uid %>">
<%

out.println(uid); %>
</option>
<%}%>
</select></td></tr>


<tr><td>Designation:</td><td><input type=text name="Desig" size=25 ></td></tr>
<tr><td>Qualification:</td><td><input type=text name="Qualify" size=25 ></td></tr>

<tr><td><a href="http://localhost:8080/ProjectAd/Orders"><input type=submit name=submit value="InsertOrder"></a></td>
<td><input type=reset name=reset value="Reset"></td></tr>
</table>
</center>
</form>
<p align=center><a href="http://localhost:8080/ProjectAd/Main.html"><img src="images/home_ap.jpg" height=20 width=20></a>
<p align=bottom><a href="http://localhost:8080/ProjectAd/HelpOrder.html">Help</a></p>
<hr color="green">
</BODY>
</HTML>


Hello Sir,

Actually in Name Combobox i am getting values from database and in userId textbox i want that when user selects a name from the combobox its corresponding id should get displayed in the textbox field.

In this code the userid is a combobox but i want a textbox with an id of selected item in name combobox
Can u please tell me how to do it i tried but it is giving me error please reply me ?
Thank you sir.

Database fields are:Table Name Regiter.


Fields are:--
UserId
Name
Address
Email
PhoneNo.

Advertisement
View Answers

Related Tutorials/Questions & Answers:
sql
difference between sql and oracle  what is the difference between sql and oracle
sql
sql  how to get first row in sql with using where condition in sql? how to get last row in sql with using where condition in sql
Advertisements
sql
sql  I want interview sql questions   Please visit the following link: SQL Tutorials
Sql
Sql  how to find maximum of a101,a102,a103 from a table in sql
SQL
SQL  hii What is sql?   hello, SQL, which stands for Structured Query Language, is a special-purpose language used to define, access, and manipulate data. SQL is non procedural, meaning that it describes
sql
sql  returning value from a store procedure in sql with example   Please visit the following links: http://www.roseindia.net/mysql/mysql5/stored-procedures-and-functions.shtml http://www.roseindia.net/sql/create
SQL
SQL  In my computer i have microsoft sql 2008.how can i set that in the cmd.i want to use that in cmd.what is the default username and password
SQl
SQl  . Given two tables: table1(player, groundname, numcenturies); table2(ground_name, country); Write and SQL query for the following: " Select all the players from table1 who has
SQL
SQL   1)How to Store 1000 records in Oracle object. 2)Write a query for calculate highest, 3rd Highest & 10th highest salary from emp teble. 3)What is Sequence. 4)How to use rowid in Sql. 5)What is Views. 6)How
SQL
SQL  how to get ( 15 march 2011) and (15/03/2011) output using SQL   Use the following queries to get the data from database in the given format. For (15 march 2011) format: SELECT DATE_FORMAT(dob, '%d %M %Y') FROM
SQL
SQL  how to get ( 15 march 2011) and (15/03/2011) output using SQL   Use the following queries to get the data from database in the given format. For (15 march 2011) format: SELECT DATE_FORMAT(dob, '%d %M %Y') FROM
SQL
SQL Trigger query  Why we use the Trigger and what it's uses?   A database trigger is procedural code that is automatically executed..., user events, and SQL statements to subscribing applications 10)Restrict DML
SQL
, user events, and SQL statements to subscribing applications 10)Restrict DML
SQL
events, user events, and SQL statements to subscribing applications 10)Restrict DML
SQL
events, and SQL statements to subscribing applications 10)Restrict DML
SQL
tables EMP, and DEPT, the structure for which are given above. Write SQL queries
sql - SQL
order by SQL Query  What is order by in SQL and when this query is used in SQL?Thanks!  Hi,In case of mysql you can user following query.Select salary from salary_table order by salary desc limit 3,1Thanks
sql - SQL
want query? 4.what is the diffrence between sql and plsql?  Hi Friend... HAVING n>1; Difference between SQL and PL/SQL: SQL is a structured query...(select,insert,update etc.), manipulate objects(DDL) and data(DML). PL/SQL
sql - SQL
sql  write a dyamic sql program to display the name of a employee whose salary is <5000  Hi Friend, Use the following query... the following link: http://www.roseindia.net/sql/ Thanks
SQL - SQL
SQL  How to combine 'LIKE' and 'IN' operators in sql query?   select name from tab1 where name like 'R%' AND city in('bangalore','mumbai'); Table Name: tab1 FieldName ===================== | name | city
SQL - SQL
SQL  Jus c da case we hve certain images in some folder or some area in sql can we create trigger or procedure so dat in front like in asp page while clicking image it will be showed in page ...... ...I mean writing code for each
sql - SQL
sql functions with examples  I need sql functions with examples to learn fast.  Hi friend,<%@ page language="java" import...("SQL statement is not executed!"); } } catch (Exception e
sql server - SQL
sql server  what is SQL server? & what is oracle? are they same
sql server - SQL
sql server  How many no of tables can be joined in same sql server
SQL help - SQL
SQL help  Hi Deepak, Can u pls tell me what is the difference between PL/SQL and MYSQL? Is there any difference in generating the code
SQL JOINS - SQL
SQL JOINS  Hom many Joins In Sql?plz explian all those things?  Hi Friend, Please visit the following link: http://www.roseindia.net/sql/sqljoin/index.shtml Hope that it will be helpful for you. Thanks
sql component
sql component  is sql package is the component of jdbc
An SQL Locator.
An SQL Locator.  What is an SQL Locator
sql 2000 - SQL
sql 2000  why binary data when inserted into the sql column of data type image or binary is stored in the form of hexadecimal nos. instead of the name of the file inserted????? Thanx for ur response in advance
learn sql - SQL
learn sql  how to learn sql......idont know anything about programming knowledge  Hi Friend, Please visit the following link: http://www.roseindia.net/sql/ Thanks
auto sql script - SQL
auto sql script  Is there a way of generating inserts scripts using the table structure for oracle database
Advertisements
 

 

 

DMCA.com