hajjo 0 Junior Poster
<html>
<head>


<script type="text/javascript">

function formValidator(theForm)
{

if (theForm.location.value == "")
{
	alert("Please choose a location");
	theForm.location.focus();
	return (false);
}

 if ( ( theForm.browser[0].checked == false ) && ( theForm.browser[1].checked == false ) && ( theForm.browser[2].checked == false )  && ( theForm.browser[3].checked == false ))
 {
		alert("please choose a subscription way");
		theForm.browser[0].focus();
		theForm.browser[1].focus();
		theForm.browser[2].focus();
		theForm.browser[3].focus();
		return (false);
 } 
 


	

if (theForm.loginName.value == "")
{
	alert("Please enter a loginname");
	theForm.loginName.focus();
	return (false);
}

if (theForm.password.value == "")
{
	alert("Please enter a password");
	theForm.password.focus();
	return (false);
}

if (theForm.comment.value == "")
{
	alert("Please enter a comment");
	theForm.comment.focus();
	theForm.comment.blur();
	return (false);
}

// require at least 5 characters in the password field
if (theForm.password.value.length > 20)
{
	alert("Please enter at most 20characters in the \"Password\" field.");
	theForm.password.focus();
	return (false);
}

// check if both password fields are the same
if (theForm.password.value != theForm.password2.value)
{
	alert("The two passwords are not the same.");
	theForm.password2.focus();
	return (false);
}

// allow only 150 characters maximum in the comment field
if (theForm.comment.value.length > 150)
{
	alert("The comments no more then 150 line please.");
	theForm.comment.focus();
	return (false);
	}
	
if(!theForm.chalet[0].checked && !theForm.chalet[1].checked)
{
	alert("please select at least one rent choice");
	return (false);
}



if(theForm.chalet[0].checked && !theForm.chalet[1].checked)
{
	if(theForm.browser[0].checked == true)
		document.getElementById('textFromJavascriptHolder').innerHTML = "Dear MR/MRS " +theForm.loginName.value+ " <br><You have chosen to spent the best " +theForm.browser[0].value+ " of your life in one of our most beautiful resorts of lebanon " + theForm.chalet[0].value+ " <br>In order to provide you with more detatils please login to our site using loginname " +theForm.loginName.value+ " password " + theForm.password.value+ " <br>thank you for choosing " +  theForm.location.value+ " to spend your vacation";
	if(theForm.browser[1].checked == true)
		document.getElementById('textFromJavascriptHolder').innerHTML  = "Dear MR/MRS " +theForm.loginName.value+ "<br> You have chosen to spent the best " +theForm.browser[1].value+ " of your life in one of our most beautiful resorts of lebanon " + theForm.chalet[0].value+  " <br>In order to provide you with more detatils please login to our site using loginname " +theForm.loginName.value+ " password " + theForm.password.value+ "<br> thank you for choosing " +  theForm.location.value+ " to spend your vacation";
	if(theForm.browser[2].checked == true)
		document.getElementById('textFromJavascriptHolder').innerHTML = "Dear MR/MRS " +theForm.loginName.value+ "<br> You have chosen to spent the best " +theForm.browser[2].value+ " of your life in one of our most beautiful resorts of lebanon " + theForm.chalet[0].value+  "<br> In order to provide you with more detatils please login to our site using loginname " +theForm.loginName.value+ " password " + theForm.password.value+ "<br> thank you for choosing " +  theForm.location.value+ " to spend your vacation";
	if(theForm.browser[3].checked == true)
	{

		document.getElementById('textFromJavascriptHolder').innerHTML  = "Dear MR/MRS " +theForm.loginName.value+ " <br>You have chosen to spent the best " +theForm.Item.options[theForm.Item.selectedIndex].value+ " of your life in one of our most beautiful resorts of lebanon " + theForm.chalet[0].value+  "<br> In order to provide you with more detatils please login to our site using loginname " +theForm.loginName.value+ " password " + theForm.password.value+ "<br> thank you for choosing " +  theForm.location.value+ " to spend your vacation";
	
	}
}
else if(theForm.chalet[1].checked && !theForm.chalet[0].checked)
{
	if(theForm.browser[0].checked == true)
		document.getElementById('textFromJavascriptHolder').innerHTML = "Dear MR/MRS " +theForm.loginName.value+ "<br> You have chosen to spent the best " +theForm.browser[0].value+ " of your life in one of our most beautiful resorts of lebanon "+ theForm.chalet[1].value+  " <br>In order to provide you with more detatils please login to our site using loginname " +theForm.loginName.value+ " password " + theForm.password.value+ " <br>thank you for choosing " +  theForm.location.value+ " to spend your vacation";
	if(theForm.browser[1].checked == true)
		document.getElementById('textFromJavascriptHolder').innerHTML  ="Dear MR/MRS " +theForm.loginName.value+ "<br> You have chosen to spent the best " +theForm.browser[1].value+ " of your life in one of our most beautiful resorts of lebanon " + theForm.chalet[1].value+  " <br>In order to provide you with more detatils please login to our site using loginname " +theForm.loginName.value+ " password " + theForm.password.value+ "<br> thank you for choosing " +  theForm.location.value+ " to spend your vacation";
	if(theForm.browser[2].checked == true)
		document.getElementById('textFromJavascriptHolder').innerHTML  = "Dear MR/MRS " +theForm.loginName.value+ "<br> You have chosen to spent the best " +theForm.browser[2].value+ " of your life in one of our most beautiful resorts of lebanon " + theForm.chalet[1].value+" <br>In order to provide you with more detatils please login to our site using loginname " +theForm.loginName.value+ " password " + theForm.password.value+ " <br>thank you for choosing " +  theForm.location.value+ " to spend your vacation";
	if(theForm.browser[3].checked == true)
	{

		document.getElementById('textFromJavascriptHolder').innerHTML = "Dear MR/MRS " +theForm.loginName.value+ "<br> You have chosen to spent the best " +theForm.Item.options[theForm.Item.selectedIndex].value+ " of your life in one of our most beautiful resorts of lebanon " + theForm.chalet[1].value+  " <br>In order to provide you with more detatils please login to our site using loginname " +theForm.loginName.value+ " password " + theForm.password.value+ " <br>thank you for choosing " +  theForm.location.value+ " to spend your vacation";

	}
}
else 
{
	if(theForm.browser[0].checked == true)
		document.getElementById('textFromJavascriptHolder').innerHTML = "Dear MR/MRS " +theForm.loginName.value+ "<br> You have chosen to spent the best " +theForm.browser[0].value+ " of your life in one of our most beautiful resorts of lebanon "+ theForm.chalet[1].value+ " " +theForm.chalet[0].value+   " <br>In order to provide you with more detatils please login to our site using loginname " +theForm.loginName.value+ " password " + theForm.password.value+ " <br>thank you for choosing " +  theForm.location.value+ " to spend your vacation";
	if(theForm.browser[1].checked == true)
		document.getElementById('textFromJavascriptHolder').innerHTML = "Dear MR/MRS " +theForm.loginName.value+ "<br> You have chosen to spent the best " +theForm.browser[1].value+ " of your life in one of our most beautiful resorts of lebanon " + theForm.chalet[1].value+ "" + theForm.chalet[0].value+   " <br>In order to provide you with more detatils please login to our site using loginname " +theForm.loginName.value+ " password " + theForm.password.value+ "<br> thank you for choosing " +  theForm.location.value+ " to spend your vacation";
	if(theForm.browser[2].checked == true)
		document.getElementById('textFromJavascriptHolder').innerHTML = "Dear MR/MRS " +theForm.loginName.value+ "<br> You have chosen to spent the best " +theForm.browser[2].value+ " of your life in one of our most beautiful resorts of lebanon " + theForm.chalet[1].value+ " " + theForm.chalet[0].value+ " <br>In order to provide you with more detatils please login to our site using loginname " +theForm.loginName.value+ " password " + theForm.password.value+ " <br>thank you for choosing " +  theForm.location.value+ " to spend your vacation";
	if(theForm.browser[3].checked == true)

	{

		document.getElementById('textFromJavascriptHolder').innerHTML  = "Dear MR/MRS " +theForm.loginName.value+ "<br> You have chosen to spent the best " +theForm.Item.options[theForm.Item.selectedIndex].value+ " of your life in one of our most beautiful resorts of lebanon " + theForm.chalet[1].value+ " " + theForm.chalet[0].value+   " <br>In order to provide you with more detatils please login to our site using loginname " +theForm.loginName.value+ " password " + theForm.password.value+ " <br>thank you for choosing " +  theForm.location.value+ " to spend your vacation";

	}
}

}
function favBrowser()
{
	var mylist=document.getElementById("myList");
	if(value=mylist.options[mylist.selectedIndex].text=="Eddeh Sands")
	{
		document.getElementById("favorite").value = "Jbeil";
	}
	if(value=mylist.options[mylist.selectedIndex].text=="Oceana")
	{
		document.getElementById("favorite").value = "Damour";
	}
	if(value=mylist.options[mylist.selectedIndex].text=="Bamboo Jay")
	{
		document.getElementById("favorite").value = "Jiyye";
	}
	
}

function checking()
{
	document.getElementById("myList1").style.display = "block";
}



</script>
</head>

<body bgcolor="Red">
<form  name="Form1"  >
<p style="color:Blue;font-size:12pt">Resort name:
<select id="myList" onchange="favBrowser()">
  <option>Eddeh Sands</option>
  <option>Oceana</option>
  <option>Bamboo Jay</option>
</select></p>
<p style="color:Blue;font-size:12pt">Location: <input type="text" id="favorite" name="location" size="20" readOnly = true>
</p>
<p></p>
<p style="color:Blue;font-size:12pt">Membership:</p>

<input type="radio" name="browser"  value="1 Month">1 Month
<input type="radio" name="browser"   value="3 Month">3 Month
<input type="radio" name="browser"   value="1 Year">1 Year
<input type="radio"  name="browser" onclick="checking()"  value="Others">Others
<select style="display:none" id="myList1"  name="Item">
  <option>2 years</option>
  <option>3 years</option>
  <option>lifetime</option>
</select>
<br />
<br />
<br />

<p style="color:Blue;font-size:12pt">Rent Choice:</p> <input type="checkbox" color="Black" name="chalet" value="chalet">Chalet
<input type="checkbox" color="Black" name="chalet" value="cabinet">Cabinet<br />

<hr></hr>
<p style="color:Blue;font-size:12pt"> Login Name:<input type="text" name="loginName"></br></p>
<p style="color:Blue;font-size:12pt">Password: <input type="password" id="password" name="password" size="20" ></p>
<p style="color:Blue;font-size:12pt">Password Confirmation: <input type="password" name = "password2" size="20"></br></p>
<p style="color:Blue;font-size:12pt">Comments: <br><textarea name="comment" rows="4" cols="50" wrap="virtual">
</textarea></p>
<hr></hr>



<input type="button" onClick="return formValidator(document.Form1)" value="Submit"  >
<input type="reset" name="Reset" value="Reset">
<div id="textFromJavascriptHolder"></div>

</form>



 </script>
</body>

</html>

This is the firrst code which is too simple. Now the username and password he writes will be written to the database. The code for that is.

<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.text.*" %>

 
 <%
 
    String name = request.getParameter( "loginName" );
   session.setAttribute( "theName", name );
   String name1 = request.getParameter("password");
   session.setAttribute("theage", name1);

//Statement stmt =null;
Connection conn =null;
//Statement stmt;
//Connection conn;
//ResultSet rs = null;
PreparedStatement pstatement = null;
 int updateQuery = 0;
     
try
{
String url = "jdbc:oracle:thin:@ahmad:1521:ORCL";
String user = "training";
String password = "training";
Class.forName("oracle.jdbc.driver.OracleDriver");
//Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//Class.forName("Oracle.jdbc.odbc.OracleOdbcDriver").newInstance(); 
System.out.println("--------------");
//Get a connection to the database
conn = DriverManager.getConnection(url, user, password);
//Get a statement from the connection
//stmt = conn.createStatement();

}
catch(Exception ex)
{
	System.out.println("Error in creating the connection  :"+ex.getMessage());
}




try
{
	String Query="";
	Query="INSERT INTO usernamepassword(username, password) VALUES(?,?)";
        pstatement.setString(1, name);
			  pstatement.setString(2, name1);

        
	System.out.println("Query========================="+Query);


	//Execute the Query and return the resultSet
	   pstatement = conn.prepareStatement(Query);

                       
            updateQuery = pstatement.executeUpdate();




}

catch (Exception exp)
{
   System.out.println("Error in Query execution " + exp.getMessage());
}

finally
{
  //if(stmt != null)
  //stmt.close();
   //if(conn != null)
    pstatement.close();

   conn.close();
}
%>

Huge question is, how do i call the .jsp page to write into the query in the first .html file. where do i call it?