Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

what is wrong with this

Status
Not open for further replies.

ramblenman

Technical User
Joined
Sep 27, 2003
Messages
14
Location
CA
I have some pics. they all have a different value assigned to them. I want the photo that is chosen to show up on a new page and the value to be used later in a caculation. I have come up with this script(with some help), but it will not direct me to the new page.

<html>
<head>
<title>Chiller</title>

<script type="text/javascript">
<!--
function calculate(bottle) {
var totalAmount=bottle*10;

}
// -->
</script>

</head>
<body>

<form action="">
<a href="page2.html?pic=chr500ml.jpg&calc=.01"><input type="image" src="

chr500ml.jpg" onclick="calculate(0.01)"/></a>

<a href="page2.html?pic=db500ml.jpg&calc=.02"><input type="image" src="db

500ml.jpg" onclick="calculate(0.02)"/></a>

<a href="page2.html?pic=cw375ml.jpg&calc=.03"><input type="image" src="cw

375ml.jpg" onclick="calculate(0.03)"/></a>

</form>

</body>
</html>


Thanks for your help
 
JavaScript doesn't remember variables from one page to another. You'd have to save the value to a cookie or pass it in the querystring. Why don't you wait and do the calculation on the next page instead?

Adam
while(ignorance){perpetuate(violence,fear,hatred);life=life-1};
 
If the new page only display a picture of the item, why not just have a pop up window shw the picture while keeping the main page with all the calculating open?

<html>
<head>
<title>Chiller</title>
<script type="text/javascript">
<!--
var totalAmount = 0
function calculate(bottle,picture) {
  totalAmount =+ bottle*10;
  window,open(picture,'mypictures','width=200,height=300')
document.myform.mytotal.value = totalAmount;
return false;
}
// -->
</script>
</head>
<body>
<form name = "myform" action="">
<a href="page.html><image src="
chr500ml.jpg" border = 0 onclick="return calculate(0.01,'chr500ml.jpg')"/></a><BR>
<a href="page.html><image src="
db500ml.jpg" border = 0 onclick="return calculate(0.02,'db500ml.jpg')"/></a><BR>
<a href="page.html><image src="
cw375ml.jpg" border = 0 onclick="return calculate(0.03,'cw375ml.jpg')"/></a><BR>
Total: <input type="text" name="mytotal">
</form>
</body>
</html>

 
Mbiro, Thanks, thats a good idea.. I think I mat just do that.
Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top