Jsp

Jsp

PlaceAd.jsp

<%@page import="java.sql.*"%>
<%@page import="java.io.*"%>
<%@page import="java.lang.*"%>
<%
Connection con=null;
Statement stmt=null;
int Num=0;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:Advdsn");
stmt=con.createStatement();

}
catch(SQLException se){
out.println("Database Error:"+se.getMessage());
}
catch(Exception e){
e.toString();
}
%>

<html>
<head>

<script src="City.js"></script>
<script language="Javascript">

function Calculate()
{
<!--Front Page-->
var fpval;
var cityamt;
var newspaper;
var sizeval;
var city = document.form.city.value;
var noofwd = document.form.Count.value;
var nofw = document.form.Count.value;
var payat = document.form.Total;

<!--Andhra Pradesh-->
if (city.toUpperCase() == "HYDERBAD")
{cityamt = 450;}
else if (city.toUpperCase() == "VISAKHAPATNAM")
{cityamt = 300;}
else if (city.toUpperCase() == "VIJAYAWADA")
{cityamt = 200;}

<!--Bihar-->
if (city.toUpperCase() == "BIHAR")
{cityamt = 500;}

<!--Delhi-->
if (city.toUpperCase() == "DELHI")
{cityamt = 1000;}

<!--Gujarat-->
if (city.toUpperCase() == "AHMEDABAD")
{cityamt = 600;}
else if (city.toUpperCase() == "VADODARA")
{cityamt = 400;}
else if (city.toUpperCase() == "SURAT")
{cityamt = 300;}
else if (city.toUpperCase() == "GANDHINAGAR")
{cityamt = 200;}

<!--Haryana-->
if (city.toUpperCase() == "CHANDIGARH")
{cityamt = 400;}
else if (city.toUpperCase() == "GURGAON")
{cityamt = 300;}

<!--Himachal Pradesh-->
if (city.toUpperCase() == "SHIMLA")
{cityamt = 500;}
else if (city.toUpperCase() == "KULLU")
{cityamt = 400;}
else if (city.toUpperCase() == "MANALI")
{cityamt = 400;}

<!--Jammu and Kashmir-->
if (city.toUpperCase() == "JAMMU")
{cityamt = 600;}
else if (city.toUpperCase() == "SRINAGAR")
{cityamt = 600;}

<!--Karnataka-->
if (city.toUpperCase() == "BANGALORE")
{cityamt = 800;}
else if (city.toUpperCase() == "MYSORE")
{cityamt = 600;}
if (city.toUpperCase() == "MANGALORE")
{cityamt = 400;}
else if (city.toUpperCase() == "UDUPI")
{cityamt = 300;}

<!--Maharastra-->
if (city.toUpperCase() == "MUMBAI")
{cityamt = 1000;}
else if (city.toUpperCase() == "PUNE")
{cityamt = 120;}
else if (city.toUpperCase() == "NASIK")
{cityamt = 240;}
else if (city.toUpperCase() == "NAGPUR")
{cityamt = 360;}

<!--Rajasthan-->
if (city.toUpperCase() == "AJMER")
{cityamt = 400;}
else if (city.toUpperCase() == "JAIPUR")
{cityamt = 500;}
else if (city.toUpperCase() == "JODHPUR")
{cityamt = 300;}
else if (city.toUpperCase() == "BIKANER")
{cityamt = 300;}
else if (city.toUpperCase() == "UDAIPUR")
{cityamt = 300;}

<!--TamilNadu-->
if (city.toUpperCase() == "CHENNAI")
{cityamt = 1000;}
else if (city.toUpperCase() == "THANJAVUR")
{cityamt = 400;}
else if (city.toUpperCase() == "COIMBATORE")
{cityamt = 500;}
else if (city.toUpperCase() == "RAMESHWARAM")
{cityamt = 400;}
else if (city.toUpperCase() == "TRICHY")
{cityamt = 500;}

<!--Uttar Pradesh-->
if (city.toUpperCase() == "AGRA")
{cityamt = 400;}
else if (city.toUpperCase() == "LUCKNOW")
{cityamt = 300;}
else if (city.toUpperCase() == "VARANASI")
{cityamt = 300;}
else if (city.toUpperCase() == "ALLAHABAD")
{cityamt = 300;}

<!--West Benegal-->
if (city.toUpperCase() == "KOLKATA")
{cityamt = 1000;}
else if (city.toUpperCase() == "DARJEELING")
{cityamt = 400;}

<!--Mumbai Mirror-->
var mmval;
if(!document.form.MM.checked) {
mmval = 0
}
else
{
mmval = wordrate(730, 130, nofw);
}


<!--TOI-->
var tival;
if(!document.form.TOI.checked) {
tival = 0
}
else
{
tival = wordrate(2360, 400, nofw);
}


<!--ET-->
var etval;
if(!document.form.ET.checked) {
etval = 0
}
else
{
etval = wordrate(950, 200, nofw);
}


<!--Midday-->
var meval;
if(!document.form.ME.checked) {
meval = 0
}
else
{
meval = wordrate(500, 20, nofw);
}

<!--Hindustan Times-->
var htval;
if(!document.form.HT.checked) {
htval = 0; }
else
{
htval = wordrate(300, 50, nofw);
}

<!--DNA-->
var dval;
if (!document.form.DNA.checked) {dval =0;}
else
{
dval = wordrate(600, 75, nofw);
}

<!--Indian Express-->
var ieval;
if (!document.form.IE.checked) {ieval = 0;}
else
{
ieval = wordrate(160, 15, nofw);
}

<!--Color-->
var colval;
if (!document.form.col.checked) { colval = 0;}
else { colval = 1000;}

<!--B&W-->
var bwval;
if (!document.form.bw.checked) { bwval = 0;}
else { bwval = 500;}


<!--img-->
var imgrate;
if(!document.form.img.value) {imgrate = 0;}
else {imgrate = 200;}


<!--size-->


if (form.size.options[form.size.selectedIndex].text == "3*3")
{ sizeval = 100;}
if (form.size.options[form.size.selectedIndex].text == "3*5")
{ sizeval = 200;}
if (form.size.options[form.size.selectedIndex].text == "4*1")
{ sizeval = 300;}
if (form.size.options[form.size.selectedIndex].text == "4*4")
{ sizeval = 400;}

<!--Front Page-->
var fpval;
if (!document.form.fp.checked) { fpval = 0;}
else { fpval = 1000;}

<!--Back Page-->
var bpval;
if (!document.form.bp.checked) { bpval = 0;}
else { bpval = 800;}

<!--Page2-->
var p2val;
if (!document.form.p2.checked) { p2val = 0;}
else { p2val = 600;}

<!--Page3-->
var p3val;
if (!document.form.p3.checked) { p3val = 0;}
else { p3val = 400;}

<!--Page5-->
var p5val;
if (!document.form.p5.checked) { p5val = 0;}
else { p5val = 200;}

<!--Page7-->
var p7val;
if (!document.form.p7.checked) { p7val = 0;}
else { p7val = 100;}

var pageval;
pageval = fpval+bpval+p2val+p3val+p5val+p7val;
payat.value = cityamt+mmval+tival+etval+meval+htval+dval+ieval+sizeval+colval+bwval+pageval+imgrate;

}

function wordrate(baserate, extrarate, numberofwords)
{
var extwrds;
var totrate;
totrate = baserate;

if (numberofwords > 15)
{
extwrds = numberofwords - 15;
}
for (i=0; i<extwrds; i++)
{
totrate = totrate + extrarate;
}
return totrate;
}

function Draft(text1,text2){
var v1=text1.value;
var v = 0;
v2=v1.replace(/\s/g,' ');
v2=v2.split(' ');
for (i=0; i<v2.length; i++) {if (v2[i].length > 0) v++;}
text2.value=v;
}
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 phone=document.form.PhoneNo;
var email=document.form.Email;
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;
}

</script>
</head>
<% String Or=request.getParameter("order"); %>
<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><b> <font color="669933" size=4>Place Ad</font></b></p><br>

<form name="form" method="post" action="http://localhost:8080/ProjectAd/Preview.jsp" onsubmit="return Validate();">

<table>
<tr><td>OrderNo:</td><td><input type=text name="OrderNo" value="<%=Or%>" readonly></td></tr>


<tr>
<td style="text-align: left;">State:</td>
<td style="text-align: left;">
<select name="State" id="state" onchange="setCities();">
<option value="Andhra Pradesh">Andhra Pradesh</option>
<option value="Bihar">Bihar</option>
<option value="Delhi">Delhi</option>
<option value="Gujarat">Gujarat</option>
<option value="Haryana">Haryana</option>
<option value="Himachal Pradesh">Himachal Pradesh</option>
<option value="Jammu and Kashmir">Jammu and Kashmir</option>
<option value="Karnataka">Karnataka</option>
<option value="Maharashtra">Maharashtra</option>
<option value="Rajasthan">Rajasthan</option>
<option value="TamilNadu">TamilNadu</option>
<option value="Uttar Pradesh">Uttar Pradesh</option>
<option value="West Benegal">West Benegal</option>
</select>
</td>
</tr><tr>
<td style="text-align: left;">City:</td>
<td style="text-align: left;">
<select name="City" id="city">
<option value="">Please select a State</option>
</select>
</td>
</tr>
<tr>
<td style="text-align: left;">Main Category:</td>
<td style="text-align: left;">
<select name="mainCat" id="mainCat" onchange="setCategory();">
<option value="Electronics & Technology">Electronics & Technology</option>
<option value="Home & Lifestyle">Home & Lifestyle</option>
<option value="Real Estate">Real Estate</option>
<option value="Cars & Bikes">Cars & Bikes</option>
<option value="Jobs">Jobs</option>
<option value="Services">Services</option>
<option value="Entertainment">Entertainment</option>
<option value="Pets and Pet Care">Pets and Pet Care</option>
<option value="Community">Community</option>
<option value="Events">Events</option>
<option value="Matrimonial">Matrimonial</option>

</select>
</td>
</tr><tr>
<td style="text-align: left;">Sub Category:</td>
<td style="text-align: left;">
<select name="subCat" id="subCat">
<option value="">Please select Main Category</option>
</select>
</td>
</tr>
<tr><td>Title:</td><td> <input type=text name="Title" size=25 ></td></tr>
<tr><td>Draft Your Ad here:</td><td><textarea name="DraftAd" cols="25" rows="5" onkeyup="Draft(this,document.form.Count)"></textarea></td></tr>
<tr><td>No of words:</td><td><input name="Count" type="text" value="0" onkeyup="Draft(document.form.DraftAd,this)" readonly></td></tr>
<tr><td>Image:</td><td><input type="file" name="img"></td></tr>
<tr><td>Email:</td><td><input type=text name="Email" size=25></td></tr>
<tr><td>Phone No:</td><td><input type=text name="PhoneNo" size=25 maxlength=10></td></tr>
</table>

<hr color=green>
<p align=center><b> <font color="669933" size=4>Schedule </font></b></p><br>

<table>
<tr><td>Select Newspaper:</td></tr>
<tr><td><input type=checkbox name=NP value="TimesOfIndia" id="TOI">Times of India</td>
<td><input type=checkbox name=NP value="MumbaiMirror" id="MM">Mumbai Mirror</td>
<td><input type=checkbox name=NP value="EconomicTimes" id="ET">Economic Times</td></tr>
<tr><td><input type=checkbox name=NP value="HindustanTimes" id="HT">Hindustan times</td>
<td><input type=checkbox name=NP value="DNA" id="DNA">DNA</td>
<td><input type=checkbox name=NP value="IndianExpress" id="IE">Indian Express</td></tr>
<tr><td><input type=checkbox name=NP value="MiddayEnglish" id="ME">Midday English</td>

<tr><td>Ad Size:</td><td><select name="size" size=1>
<option value="3*3">3*3</option>
<option value="3*5">3*5</option>
<option value="4*1">4*1</option>
<option value="4*4">4*4</option>
</select></td></tr>
<tr><td>Select Color or B&W: <input id="col" type="radio" name="COLBW" value="Color">Color</td>
<td><input id="bw" type="radio" name="COLBW" value="B/W">B & W</td></tr>

<tr><td>Select Your Date:</td><td><select name="day" size=1>

<%for (int date=1;date<=31;date++)
{
%>
<option value="<%=date%>"><%=date%></option>
<%}%>
</select></td></tr>
<tr><td>Month:</td><td><select name="Month" size=1>
<%
for (int month=1;month<=12;month++){
%>
<option value="<%=month%>"><%=month%></option>
<%}%>
</select></td></tr>
<tr><td>Year:</td><td><select name="Year" size=1>
<%
for (int year=2010;year<=2050;year++){
%>
<option value="<%=year%>"><%=year%></option>
<%}%>
</select></td></tr>

</table>

<hr color=green>
<p align=center><b> <font color="669933" size=4>Payment </font></b></p><br>

<p><b><font color="#336633">Premium Position</font></b></p><br>

<table>
<tr><td><input type=radio name=Page id=fp value="FrontPage">FrontPage</td></tr>
<tr><td><input type=radio name=Page id=bp value="BackPage">BackPage</td></tr>
</table>


<p><b><font color="#336633">Other Premium Pages</font></b></p><br>


<table>
<tr><td><input type=radio name=Page id=p2 value="Page2">Page 2</td></tr>
<tr><td><input type=radio name=Page id=p3 value="Page3">Page 3</td></tr>
<tr><td><input type=radio name=Page id=p5 value="Page5">Page 5</td></tr>
<tr><td><input type=radio name=Page id=p7 value="Page7">Page 7</td></tr>
<tr><td>Select Number of Days:</td><td><input type=text name="numDays" size=5></td></tr>

<tr><td>Total Cost:</td><td><input type=text name=Total onClick="Calculate()" size=5 ></td></tr>
<tr><td><input type="submit" name="submit" value="DisplayAd"></td></tr>

</table>

</form>
</body>
</html>

Hello Sir,
Actually Sir in this form there is a option say Color or Black or White(B/W) so if user selects color radio button he must get a listbox with different color combinations in ti and if he selects any of the color from it then his text i.e foreground should get change to that color.
The text that he would write will be in DraftAd textarea. And if he selects submit that should be get previewed in next page.
with same color effects as he(user) chose in the option.
Please Reply me Sir Actually i tried a lot but not getting it please reply me??
Thank you Sir.
View Answers

March 16, 2010 at 4:55 PM

Hi Friend,

Use the following code:

<script>
function Change(){
selIdx = document.forms[0].combo.selectedIndex;
newSel = document.forms[0].combo.options[selIdx].text;

var col=document.getElementById("text").style.backgroundColor
document.getElementById("text").style.color=newSel;
}
</script>
<form>

<textarea id="text" cols="20" rows="10">jhgdyauydyywtr yugweyrtwety</textarea>
<select name="combo" onchange="Change();">
<option value="White">Select</option>
<option value="Violet">Violet</option>
<option value="Indigo">Indigo</option>
<option value="Blue">Blue</option>
<option value="Green">Green</option>
<option value="Yellow">Yellow</option>
<option value="Orange">Orange</option>
<option value="Red">Red</option>
</form>

Hope that it will be helpful for you.
Thanks









Related Tutorials/Questions & Answers:
jsp
jsp  how jsp translated into servlets
JSP
JSP  How to run jsp program in eclipse
Advertisements
jsp
jsp  how to create jsp page
Jsp
Jsp  Can I implement interface in jsp
JSP
what is JSP forward tag for  what is JSP forward tag for   It forwards the current request to another JSP page. Below is the syntax for the same:- <jsp:forward page="...url..." /> We can also forward parameter
jsp
jsp  how to include two jsp page
jsp
jsp  how to create a table in oracle using jsp and the table name is entered in text feild of jsp page
jsp
jsp  write a code for jsp file generator to generate a jsp page automatically taking html page as input
JSP
JSP  Hi, What is JSP? What is the use of JSP? Thanks   Hi, JSP Stands for Java Server Pages. It is Java technology for developing web applications. JSP is very easy to learn and it allows the developers to use Java
jsp
jsp   what is the basic necessities reguired for running jsp using JDBC bridge?? and how to write a jsp code to access the detail present in microsoft access pls send link regarding above
jsp
jsp  how to pass jsp variable to an html page
JSP
JSP  relevant difference between servlet and jsp in 1 line
jsp
jsp  how to include google map in our jsp page
JSP
JSP   How to create CAPTCHA creation by using JSP? I need an code for CAPTCHA creation by using JSP...   You can create a captcha validation using jsp. Have a look at the following tutorial: Captcha Creation
jsp
jsp  how to write a servlet and jsp program for user login form
jsp
jsp  how to write a servlet and jsp program for user login form
jsp
jsp  why jsp is translated into servlet?pls describe precisly
jsp
jsp  code for jsp automatic genration using html
jsp
jsp  how to write hindi in jsp and store in database as unicode
JSP
JSP  FILE UPLOAD-DOWNLOAD code USING JSP
jsp
jsp  how to delete data from database using jsp
jsp
jsp  I Want complete note on JSP servlet
jsp
jsp  how to upload image through csv format in jsp
JSP
What are JSP directives, page directives and include directives?  what are jsp directives? and what are page directives? and what are include directives? can you explain taglib directives?   JSP directives JSP
JSP
Can you explain jsp page life cycle what is el how does el search for an attribute in JSP  Can you explain jsp page life cycle what is el how does el...://www.roseindia.net/jsp/simple-jsp-example/LifeCycleOfJspPage.shtml http
JSP
JSP  what are the different scopes an object can have in a jsp page   JSP Scope Variables: Page scope-It makes the data available... the following links: http://www.roseindia.net/jsp/simple-jsp-example
jsp
jsp  how to connect the database with jsp using mysql   Hi Friend, Please visit the following links:ADS_TO_REPLACE_1 http://www.roseindia.net/jsp/connectjspwith_mysql.shtml http://www.roseindia.net/jsp
JSP
what is jstl in JSP   what is jstl   JSTL is also called as JSP tag libraries. They are collection of custom actions which canbe accessed as JSP tags. For more information, visit the following link: JSTL Tutorials
JSP
access application data stored in JavaBeans components. The jsp expression...). Before JSP 2.0, we could use only a scriptlet, JSP expression, or a custom tag to include server state in the jsp page output. For more information, visit
JSP
JSP public opinion poll   Develop a JSP for a news channel to conduct public opinion poll on any topic. Users will respond through yes or no options. Later display the result in percentage
jsp
jsp   Hi all..I am new in jsp. I have a question. I want develope a jsp page it contain two part for two different user group. i want to hide some information from user1 group and same as user2 group. can i do this in single jsp
jsp
jsp  hai please give me the table grid code code for jsp
jsp
jsp  how to create multiple tables in oracle 9i using jsp program
jsp
jsp  Dear deepak, wat is the purpose of converting jsp into servlet and how the process takes place.. with regards, praveen
jsp
jsp  how to assign javascript varible to java method in jsp without using servlet
JSP
JSP  why we use preparedstatement while saving data from jsp to data base table
jsp
jsp  In any jsp all implicit objects are available directly, in such a case why we need PageContext object again
JSP
JSP  how does jsp engines instantiae tag handler classes instances   JSP engines will always instantiate a new tag handler instance every time a tag is encounteredin a JSP page. A pool of tag instances are maintained
jsp
jsp  Hi in my dao class some exception is there then how can i display in jsp page
JSP
JSP  How to include the same jsp page dynamically to a number of times automatically
JSP
JSP  How to include the same jsp page dynamically to a number of times automatically
jsp
jsp  how to edit only one row from multiple row from single jsp page dynamically
jsp
jsp  sir i want to jsp code for online examination like as bank po,,,,,,plz help me sir
jsp
jsp  in my project i have following jsp in this jsp the pagesize=30 but i have to create drop down box with values 10,20,30. and i have to pass them to pagesize how can i do this please help me
JSP
JSP   What is JSP?   JavaServer Pages (JSP) is a server-side Java technology an extension to the Java servlet technology that helps... Pages (JSP) is a server-side Java technology an extension to the Java servlet
JSP
objects in jsp   Implicit objects in jsp are the objects... and are created at the conversion time of a jsp into a servlet. But we can pass.../o/jsp-implicit-objects.shtml
JSP
objects in jsp   Implicit objects in jsp are the objects... and are created at the conversion time of a jsp into a servlet. But we can pass.../jsp-implicit-objects.shtml
JSP
JSP  Consider that we need to have a text, combo, radio & checkbox in JSP page and the page data's are retrieved from
JSP
JSP   Develop a JSP to keep track number of users and display a message â??You are nth visitorâ?? where n is number of user
JSP
how can we use beans in jsp  how can we use beans in jsp   JSP provides three tags to work with beans:- <jsp:useBean id="bean name... that defines the bean. <jsp:setProperty name = "id" property = "someProperty" value

Ads