Jump to content


Photo

Javascript to sum total 2 drop down options...


  • Please log in to reply
1 reply to this topic

#1 joshluv33

joshluv33
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 15 August 2006 - 06:14 PM

I am working with existing php code for my photography site which generates two drop down lists.  The code retrieves Mysql info for both the size of print the client wants and separately for the color choice of the photo.  Each table in Mysql has a price associated with the product.  I would like the client to choose both options and have the sum totaled before it is sent to the cart.  Let me show you where I am at now with the code.  I appreciate any help...



#2 joshluv33

joshluv33
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 15 August 2006 - 06:26 PM

I've attached the code.  Again I appreciate any help with this.

	function addprice(str)
	{
		var itemLoc,itemLocLink;
		itemLoc=document.getElementById('add2cart');
		itemLoc.href=itemLoc.href + str.value;

		itemLocLink=document.getElementById('add2cartlink');
		itemLocLink.href=itemLocLink.href + str.value;
		
	}
	</script>

  <?							
echo "<tr><td class=\"photo_details\" bgcolor=\"#000000\" style=\"border: 1px solid #eeeeee; padding: 5px;\">";
echo "<div align=\"center\" style=\"background-color: #000000; margin-bottom: 10px; padding: 3px;\"><b>Order Prints</b></div>";
$x = 1;
$print_result = mysql_query("SELECT * FROM prints where quan_avail > 0 order by 'porder'", $db);
$print_rows = mysql_num_rows($print_result);
echo "<select name='prints' onChange='addprice(this);'>";
echo "<option>Select Prints</option>";
while($print=mysql_fetch_assoc($print_result)){
$name = $print['name'];
$price = $print['price'];
$id = $print['id'];
echo "<option value='$id'>$name--->$$price</option>\n";
}
echo "</select>";
if($print->quan_avail != "999"){									
echo "<br />" . $print->quan_avail;
}										
echo "</font><br>";
?>

<?
																	
$x = 1;
$color_result = mysql_query("SELECT * FROM color", $db);
$color_rows = mysql_num_rows($color_result);
echo "<select name='color' onChange='addprice(this);'>";
echo "<option>Select Color</option>";
while($color=mysql_fetch_assoc($color_result)){
  $name = $color['name'];
  $price = $color['price'];
echo "<option value='$price'>$name--->$$price</option>\n"
}
echo "</select>";
if($print->quan_avail != "999"){									
echo "<br />" . $print->quan_avail;
}echo "</font><br>";
	?>
 <span style="float: center"><a id="add2cart" href="public_actions.php?pmode=add_cart&amp;ptype=p&amp;gid=<?=$_GET['gid'];?>&amp;sgid=<?=$_GET['sgid'];?>&amp;pid=<?=$_GET['pid'];?>&amp;prid=<?=$print->id;?>" class="photo_links"><img src="images/cart.gif" valign="middle" border="0" /></a> <a id="add2cartlink" href="public_actions.php?pmode=add_cart&amp;ptype=p&amp;gid=<?=$_GET['gid'];?>&amp;sgid=<?=$_GET['sgid'];?>&amp;pid=<?=$_GET['pid'];?>&amp;prid=" class="photo_links">Add To Cart</a></span>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users