简体   繁体   English

将数据库中的特定行设置为下拉菜单的默认值

[英]Set specific row from database as default value for drop down menu

this is my first time asking for help and I know very little about coding. 这是我第一次寻求帮助,对编码我了解得很少。 This was mostly done for me. 这大部分是为我完成的。

On a product page I have two drop down menus. 在产品页面上,我有两个下拉菜单。 One with a version select and one with a size select. 一个带有版本选择,另一个带有大小选择。 Version selection determines what sizes are offered. 版本选择确定提供的尺寸。

When the page loads the first record set for the respective product is used as initially selected. 页面加载时,将使用最初选择的相应产品的第一个记录集。

<body onload="WA_FilterAndPopulateSubList(rssize_WAJA,MM_findObj('SelectVersion'),MM_findObj('SelectSize'),0,0,false,': '); showprice()">

This is the function for showprice witch is also called in the drop menu, because whenever the user makes a selection, three values on the page switch,prize, pzn and item number (no pzn in English): 这是showprice巫婆的功能,也可以在下拉菜单中调用它,因为每当用户进行选择时,页面上的三个值分别为prize,pzn和项目编号(英文中没有pzn):

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 is the second select menu (size menu): 这是第二个选择菜单(大小菜单):

<select class="<?php echo $tmpElementClassSize; ?> name="SelectSize" id="SelectSize" onchange="showprice()">
                  <?php
do {  
?>
                  <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 would like for the size menu to initially select size "M". 我希望尺寸菜单最初选择尺寸“ M”。

Replacing this line: 替换此行:

<?php if (!(strcmp($row_rssizedefault['size_id'], $row_rssize['size']))) {echo "selected=\"selected\"";} ?>

with this line: 用这一行:

<?php echo $row_rssizedefault['size_id']?>"<?php if ($row_rssizedefault['size_id']=='4' ?>

initially selects size "M", but the prize is not displayed correctly (though it will put the product in the cart with the correct prize). 最初选择的尺寸为“ M”,但奖品显示不正确(尽管会将具有正确奖品的产品放入购物车)。 For "M" to display I also have to delete the onload in the body tag. 为了显示“ M”,我还必须删除body标记中的onload。 Otherwise it will show "M" for a split second and then change to "XS" (the first record). 否则,它将显示“ M”一秒钟,然后更改为“ XS”(第一个记录)。

Is it possible to select a default from the database in the javascript function? 是否可以在javascript函数中从数据库中选择默认值?

Sorry for the long post. 抱歉,长篇文章。 This is the link to one of the product pages: http://www.segufixshop.eu/detail_en.php?recordID=13 这是产品页面之一的链接: http : //www.segufixshop.eu/detail_en.php?recordID=13

Having the body tag like this: 具有如下的body标签:

<body onload="showprice()">

and the select attribute like this: 和select属性是这样的:

<?php if ($row_rssizedefault['size_id']=='4') {echo "selected=\"selected\"";} ?>

preselects size "M" in the size menu, but then the size menu is populated with all size choices and not size choices relevant to the version. 在尺寸菜单中预先选择尺寸“ M”,但是然后在尺寸菜单中填充所有尺寸选择,而不是与版本相关的尺寸选择。

Is it possible to change the body tag, so that the size menu will populate according to the version menu without resetting the size to "XS"? 是否可以更改body标签,以便尺寸菜单将根据版本菜单进行填充而无需将尺寸重置为“ XS”?

<body onload="WA_FilterAndPopulateSubList(rssize_WAJA,MM_findObj('SelectVersion'),MM_findObj('SelectSize'),0,0,false,': '); showprice()">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM