|
 |
|
 |
06-21-2005, 01:15 AM
|
#1 (permalink)
|
|
Registered User
Join Date: Apr 2005
Posts: 13
|
JavaScript help - printing prices in html page
Hi,
I need print a price in the empty text box at the end of each line, then give a total price, but I have nfi where to start.
Thanks for any help.
Quote:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Order Form</title>
<script language="JavaScript" type="text/javascript">
<!--
function myDate(){
var newDate=new Date();
var today=newDate.getDate();
var month=newDate.getMonth();
var year=newDate.getFullYear();
return today+"/"+month+"/"+year;
}
function startform(){
document.myform.date.value=myDate();
}
var d=new Date()
var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thu rsday","Friday","Saturday")
var monthname=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","A ug","Sep","Oct","Nov","Dec")
document.write(weekday[d.getDay()] + " ")
document.write(d.getDate() + ". ")
document.write(monthname[d.getMonth()] + " ")
document.write(d.getFullYear())
//-->
</script>
<link href="mystyle.css" rel="stylesheet" type="text/css" />
</head>
<body onload="startform()">
<form method="post" action="http:hoult.nsitweb.net/cgi-bin/testperl.pl" name="myform" id="myform" >
<h1>Phatpat's PC supplies</h1>
<table class="menu" cellspacing="2" id="mytable">
<tr>
<td class="cells"><a href="index.html">Home</a></td>
<td class="cells"><a href="order.html">Order</a></td>
<td class="cells"><a href="aboutus.html">About Us</a></td>
<td class="cells"><a href="contact.html">Contact Us</a></td>
</tr>
</table>
<h2>Place your Order here</h2>
<p>Place your order by selecting the produts you require. We only use Quality name brands when building your PC.</p>
<table class="contact" id="mytable">
<tr>
<td></td>
<td></td>
<td>Today is : <input type="text" size="10" name="date" id="date" onfocus="startform()"/></td>
</tr>
<tr>
<td> </td>
<td>
</td>
<td> </td>
</tr>
<tr>
<tr>
<td> </td>
<td>
</td>
<td> </td>
</tr>
<tr>
<tr>
<td id="cpu">CPU</td>
<td></td>
<td>AMD <select name="amd" id="amd">
<option name="none1" id="none1" value="none1">...</option>
<option name="amd30" id="amd30" value="3000+">3000+</option>
<option name="amd32" id="amd32" value="3200+">3200+</option>
<option name="amd35" id="amd35" value="3500+">3500+</option>
</select> </td>
<td id="intel">INTEL<select name="intel" id="intel">
<option name="none" id="none" value="none">...</option>
<option name="cel1" id="cel1" value="1.8">Celeron 1.8</option>
<option name="p22"value="2.2">P4 2.2ghz</option>
<option name="p24" value="2.4">P4 2.4ghz</option>
</select>
<td><input type="text" name="cpucost" id="cpucost "size="5" onfocus=""></td>
</td>
</tr>
<tr>
<td> </td>
<td>
</td>
<td> </td>
</tr>
<tr>
<tr>
<td id="ram">RAM</td>
<td></td>
<td id="ram1">RAM 1<select name="ddr1" id="ddr1">
<option name="none" id="none" value="none">...</option>
<option name="256" value="256">256mb DDR</option>
<option name="512" value="512">512mb DDR</option>
<option name="1024" value="1024">1024mb DDR</option>
</select>
</td>
<td id="ram2">RAM 2<select name="ddr2" id="ddr2">
<option name="none" id="none" value="none">...</option>
<option name="256" value="256">256mb DDR</option>
<option name="512" value="512">512mb DDR</option>
<option name="1024" value="1024">1024mb DDR</option>
</select>
<td><input type="text" name="cpucost" size="5"></td>
</td>
</tr>
<tr>
<td> </td>
<td>
</td>
<td> </td>
</tr>
<tr>
<tr>
<td id="hdd">Hard Disk</td>
<td></td>
<td>80gig<input type="radio" name="hdd80" id="hdd80" /></td>
<td>200gig<input type="radio" name="hdd200" id="hdd200" /></td>
<td><input type="text" name="cpucost" size="5"></td>
</tr>
<tr>
<td> </td>
<td>
</td>
<td> </td>
</tr>
<tr>
<tr>
<td id="GPU">Video Card</td>
<td></td>
<td></td>
<td><select name="video" id="video">
<option name="none" id="none" value="none">...</option>
<option name="n7800" id="n7800" value="n7800">Nvidia 7800</option>
<option name="n6800" id="n6800" value="n6800">Nvidia 6800</option>
<option name="a9800" id="a9800" value="a9800">ATI 9800</option>
</select>
<td><input type="text" name="cpucost" size="5"></td>
</td>
</tr>
</table>
<p>Email Address: <input type="text" name="email" id="email"></p>
<p></p>
<input type="submit" value="Submit"/> <input type="reset" value="Reload Page"/>
<p>
<a href="http://validator.w3.org/check?uri=referer"><img
src="http://www.w3.org/Icons/valid-xhtml10"
alt="Valid XHTML 1.0!" height="31" width="88" /></a>
</p>
</form>
</body>
</html>
|
|
|
|
06-21-2005, 06:34 AM
|
#2 (permalink)
|
|
Person of interest
Join Date: Mar 2003
Location: New Jersey
Posts: 102
|
Hmm, well it will take a fair amount of javascript to accomplish, but it you are serious I can talk you through it.
First I would set up a seperate pricing.js file that has a buch of hashes that map products to prices, for example:
Code:
var procs = Object;
procs['amd30'] = 120.00;
procs['amd32'] = 130.00;
procs['amd35'] = 140.00;
procs['p22'] = 130.00;
From the form id you would reference the key to get the value from the hash. Multiply that by any modifiers that would effect the price (quantity, markup, etc) then set the value of the price field that computed value.
Let me know if you have any questions.
__________________
Jeffro
Linux counter#:213782
GnuPG ID: 406238E7
|
|
|
06-21-2005, 06:43 AM
|
#3 (permalink)
|
|
Registered User
Join Date: Apr 2005
Posts: 13
|
thanx for the heads up....
I don't think i will do it that way, seems a bit to much for me...
I might remove the text boxes and see if i can get some help doing it in perl, and emailing the total, as i already have the email part working, would just need to work out how to total the prices,
it shouldnt be this hard, i think i am overcomplicating things...
hehe, typical
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -8. The time now is 02:19 PM.
|
Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
|
 |
|