this one is driving me nuts so I hope you guys can school me a bit.
My goal is to create a multiple-option dynamic pricing sheet for a product page. The concept I have is that all the information for the product is inserted in the database via relative tables. There is one table for each product where I include the basic info (id, name, description, base cost, etc) where each item will get one row. Then the relative table is for each option available (id, pid [the id for the product in the previous table], option name [such as for size 2oz], value [the additional cost for this option], option group [3 choices, a, b and c for determining which dropdown group this option belongs to]. This turned out to be like this:
php:
$a_sql = ("SELECT * FROM prod_add WHERE pid = '$id' AND `group` = 'a'");
$a_query = mysqli_query($dbconx, $a_sql);
$a_Count = mysqli_num_rows($a_query);
if ($a_Count > 0) {
while($row = mysqli_fetch_array($a_query)) {
$a_option = $row["option"];
$a_value = $row["value"];
$a_results .= "<option>$a_option [+ $ $a_value]</option>";
}
}
Which works well enough, the html for the dropdown is currently (but has been changed a lot based on the many javascript attempts i have made):
<div class="left_col">
<h3 id="price"></h3>
<?php echo $a_opt; ?><br />
<?php echo $b_opt; ?>
</div>
The javascript is what is hanging me up the most (and i know I have to cleanse variables, clean up html get rid of the breaks, etc I just want it to work then I'll clean everything up as needed). I've tried all sorts of code that I've found relevant to multiple drop downs etc, but nothing has worked. I believe it's because I'm dynamically rendering the information, but basically I need to have up to 3 drop downs created based on the groups where each selected update creates a real time update of the price. The base price is dynamic from the first table (say $100) and then the options each have a value (say $10) so when I select that option the price shows $110. I've found this tutorial http://www.javascript-coder.com/javascript-form/javascript-calculator-script.phtml which is fantastic but it isn't working properly with dynamic content, but it's very close to what I am attempting. Hope this is clear and sorry for the book but I just want to be as clear as possible. Thanks!