javascript - Set specific row from database as default value for drop down menu -
this first time asking , know little coding. done me.
on product page have 2 drop down menus. 1 version select , 1 size select. version selection determines sizes offered.
when page loads first record set respective product used selected.
<body onload="wa_filterandpopulatesublist(rssize_waja,mm_findobj('selectversion'),mm_findobj('selectsize'),0,0,false,': '); showprice()">
this function showprice witch called in drop menu, because whenever user makes selection, 3 values on page switch,prize, pzn , item number (no pzn in english):
function showprice() { var fm = document.segufix_1_atc_<?php echo $row_detailrs1["product_id"]; ?>; var selectedversion = fm.selectversion.options[document.segufix_1_atc_<?php echo $row_detailrs1["product_id"]; ?>.selectversion.selectedindex].text; var selectedsize = fm.selectsize.options[document.segufix_1_atc_<?php echo $row_detailrs1["product_id"]; ?>.selectsize.selectedindex].text; var versionset = fm.selectversion.value; var sizeset = fm.selectsize.value; var priceset = js_array[(sizeset+0+versionset)].tofixed(2); <?php if(isset($_session['languageid']) && (!($_session['languageid'] == "2" || $_session['languageid'] == "4"))) { ?> priceset = priceset.replace(".", ","); <?php } ?> var pznset = js_array2[(sizeset+0+versionset)]; var itemnolongset = js_array3[(sizeset+0+versionset)]; document.getelementbyid('pricelabel').innerhtml=' € '+priceset; document.getelementbyid('pznlabel').innerhtml=pznset; document.getelementbyid('itemnolonglabel').innerhtml=itemnolongset; }
this second select menu (size menu):
<select class="<?php echo $tmpelementclasssize; ?> name="selectsize" id="selectsize" onchange="showprice()"> <?php { ?> <option value="<?php echo $row_rssizedefault['size_id']?>"<?php if (!(strcmp($row_rssizedefault['size_id'], $row_rssize['size']))) {echo "selected=\"selected\"";} ?>><?php echo $row_rssizedefault['size']?></option> <?php } while ($row_rssizedefault = mysql_fetch_assoc($rssizedefault)); $rows = mysql_num_rows($rssizedefault); if($rows > 0) { mysql_data_seek($rssizedefault, 0); $row_rssizedefault = mysql_fetch_assoc($rssizedefault); } ?> </select>
i size menu select size "m".
replacing line:
<?php if (!(strcmp($row_rssizedefault['size_id'], $row_rssize['size']))) {echo "selected=\"selected\"";} ?>
with line:
<?php echo $row_rssizedefault['size_id']?>"<?php if ($row_rssizedefault['size_id']=='4' ?>
initially selects size "m", prize not displayed correctly (though put product in cart correct prize). "m" display have delete onload in body tag. otherwise show "m" split second , change "xs" (the first record).
is possible select default database in javascript function?
sorry long post. link 1 of product pages: http://www.segufixshop.eu/detail_en.php?recordid=13
having body tag this:
<body onload="showprice()">
and select attribute this:
<?php if ($row_rssizedefault['size_id']=='4') {echo "selected=\"selected\"";} ?>
preselects size "m" in size menu, size menu populated size choices , not size choices relevant version.
is possible change body tag, size menu populate according version menu without resetting size "xs"?
<body onload="wa_filterandpopulatesublist(rssize_waja,mm_findobj('selectversion'),mm_findobj('selectsize'),0,0,false,': '); showprice()">
Comments
Post a Comment