Shoutbox

webshop - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: webshop (/showthread.php?tid=80864)

webshop by bramvandeperre on 01-11-2008 at 01:56 PM

hi all,

i have a question, i don't know it is difficult, but if you're a little bit expierenced, keep reading anyway :p

i'm making a webshop for our school, and i want to have an automatic price calculator on product select & amount-fill-in.

code:
<div id="select1" >
<select name="productadd" onChange="document.getElementById('select2').style.display=(this.options.selectedIndex>0?'block' : 'none');"
>
<option value="" selected="selected">maak uw keuze</option>
<?php $lendetta = mysql_query("SELECT * FROM `forum_shopproduct` WHERE `actief`=1");
while ($gegeven = mysql_fetch_array($lendetta)) {
$naam = $gegeven["naam"];
$id = $gegeven["id"];
echo "<option value='".$id."'>".$naam."</option>";
}
?></select><input type="text" height="1" size="20" name="aantaladd1" value="0">

<span id="prijs1"></span><br></div>


in <span id="prijs1"></span>, there has to come a price.
the price has to be calculated like this:
code:
$query = mysql_query("SELECT * FROM `forum_shopproduct` WHERE `code`='(the value of the select-menu specified in the while)'");
$dbres = mysql_fetch_object($query);
$prijs = $dbres->prijs;


i think this is it, so the script (in js) has to determine the price live.. maybe use an array with prices or something, but you're the experienced one, not me! :p