Dynamic Dropdowns on Update Record Page
Is there a trick to using the dynamic dropdowns on an update record page? When i apply the behavior, the drop down menu will not display the current value in the database. Can you tell me how I can do this?
Is there a trick to using the dynamic dropdowns on an update record page? When i apply the behavior, the drop down menu will not display the current value in the database. Can you tell me how I can do this?
You can use the dreamweaver properties window and the "dynamic" button to set the correct value in the first list, and use the behavior "set selected in list" in the body onload event to set the value of the child list.
It still does not work. Here is my code:
<body onload="WA_setSelectionsInChildList(MM_findObj('ProductCategoryID'),<?php echo $row_WADAProducts['ProductCategoryID']; ?>)">
<div id="outerWrapper">
<div id="header">
<h1><img src="../images/WDC_Logo_200.png" alt="Warehouse Discount Center Logo" width="200" height="92" /> <span class="style2">Administrator Control Panel</span></h1>
<hr />
</div>
<div id="topNavigation">
<?php require_once("../CSSMenuWriter/cssmw_admin/menu.php"); ?>
<script type="text/javascript">if(window.attachEvent) { window.attachEvent("onload", function() { cssmw_admin.intializeMenu('cssmw_admin'); }); } else if(window.addEventListener) { window.addEventListener("load", function() { cssmw_admin.intializeMenu('cssmw_admin'); }, true); }</script>
</div>
<div id="contentWrapper">
<div id="content">
<div class="WADAUpdateContainer">
<?php if ($totalRows_WADAProducts > 0) { // Show if recordset not empty ?>
<form action="Products_Update.php?ProductID=<?php echo(rawurlencode($row_WADAProducts['ProductID'])); ?>" method="post" enctype="multipart/form-data" name="WADAUpdateForm" id="WADAUpdateForm" >
<div class="WADAHeader">Update Record</div>
<div class="WADAHorizLine"><img src="../WA_DataAssist/images/_tx_.gif" alt="" height="1" width="1" border="0" /></div>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="WADADataTable">
<tr>
<th class="WADADataTableHeader">Available Online:</th>
<td class="WADADataTableCell"><input <?php if (!(strcmp((isset($_GET['valid'])?ValidatedField("ProductsUpdate","ProductLive"):$row_WADAProducts['ProductLive']),1))) {echo "checked=\"checked\"";} ?> name="ProductLive" type="checkbox" id="ProductLive" value="1" />
(check to make this item avaiable for sale)</td>
</tr>
<tr>
<th class="WADADataTableHeader">Item Type:</th>
<td class="WADADataTableCell"><label>
<select name="SuperClass" id="SuperClass" onchange="WA_FilterAndPopulateSubList(ProductCategoryList_WAJA,MM_findObj('Class'),MM_findObj('ProductCategoryID'),0,0,false,': ')">
<option value="appliances" <?php if (!(strcmp("appliances", $row_WADAProducts['SuperClass']))) {echo "selected=\"selected\"";} ?>>Appliance Item</option>
<option value="plumbing" <?php if (!(strcmp("plumbing", $row_WADAProducts['SuperClass']))) {echo "selected=\"selected\"";} ?>>Plumbing Item</option>
</select>
</label>
<?php
if (ValidatedField("ProductsUpdate","ProductsUpdate")) {
if ((strpos((",".ValidatedField("ProductsUpdate","ProductsUpdate").","), "," . "5" . ",") !== false || "5" == "")) {
if (!(false)) {
?>
<span class="textfieldServerError">
Item type is required.</span>
<?php //WAFV_Conditional Products_Update.php ProductsUpdate(5:)
}
}
}?> </td>
</tr>
<tr>
<th class="WADADataTableHeader">Item Class:</th>
<td class="WADADataTableCell"><label>
<select name="Class" id="Class" onchange="WA_FilterAndPopulateSubList(ProductCategoryList_WAJA,MM_findObj('Class'),MM_findObj('ProductCategoryID'),0,0,false,': ')">
<?php
do {
?>
<option value="<?php echo $row_rsClass['Class']?>"<?php if (!(strcmp($row_rsClass['Class'], $row_WADAProducts['ClassId']))) {echo "selected=\"selected\"";} ?>><?php echo $row_rsClass['Class']?></option>
<?php
} while ($row_rsClass = mysql_fetch_assoc($rsClass));
$rows = mysql_num_rows($rsClass);
if($rows > 0) {
mysql_data_seek($rsClass, 0);
$row_rsClass = mysql_fetch_assoc($rsClass);
}
?>
</select>
</label>
<?php
if (ValidatedField("ProductsUpdate","ProductsUpdate")) {
if ((strpos((",".ValidatedField("ProductsUpdate","ProductsUpdate").","), "," . "12" . ",") !== false || "12" == "")) {
if (!(false)) {
?>
<span class="textfieldServerError">Item class is required.</span>
<?php //WAFV_Conditional Products_Update.php ProductsUpdate(12:)
}
}
}?></td>
</tr>
<tr>
<th class="WADADataTableHeader">Item Group:</th>
<td class="WADADataTableCell"><label>
<select name="ProductCategoryID" id="ProductCategoryID">
<?php
do {
?><option value="<?php echo $row_ProductCategoryList['CategoryID']?>"<?php if (!(strcmp($row_ProductCategoryList['CategoryID'], $row_WADAProducts['ProductCategoryID']))) {echo "selected=\"selected\"";} ?>><?php echo $row_ProductCategoryList['CategoryName']?></option>
<?php
} while ($row_ProductCategoryList = mysql_fetch_assoc($ProductCategoryList));
$rows = mysql_num_rows($ProductCategoryList);
if($rows > 0) {
mysql_data_seek($ProductCategoryList, 0);
$row_ProductCategoryList = mysql_fetch_assoc($ProductCategoryList);
}
?>
</select>
</label>
<input type="submit" name="defineCategories" id="defineCategories" value="Define..." />
<?php
if (ValidatedField("ProductsUpdate","ProductsUpdate")) {
if ((strpos((",".ValidatedField("ProductsUpdate","ProductsUpdate").","), "," . "1" . ",") !== false || "1" == "")) {
if (!(false)) {
?><span class="textfieldServerError" id="ProductCategoryIDServerValidation">
Please select a category.
</span>
<?php //WAFV_Conditional Products_Update.php ProductsUpdate(1:)
}
}
}
?>
<?php echo $row_WADAProducts['ProductCategoryID']; ?></td>
The class ID is the parent list and the ProductCategoryID is the child list.
Thanks for your help.
What does and doesn't work in this example? You need to provide a better description of where exactly you are running into problems before I could possibly know where to look.
Sorry about that.
The dynamic dropdown function works when I select a class. The only part that is not working is the body onload function to start with the product category in the recordset selected. When the page loads there is no category selected.
Thanks for responding so quickly. I really appreciate it.
OK if I understand you it is populating the parent select list, but not the child... correct?
Try updating:
<body onload="WA_setSelectionsInChildList(MM_findObj('Pr oductCategoryID'),<?php echo $row_WADAProducts['ProductCategoryID']; ?>)">
and make it:
<body onload="WA_setSelectionsInChildList(MM_findObj('Pr oductCategoryID'),'<?php echo $row_WADAProducts['ProductCategoryID']; ?>')">
No - that did not fix the problem. It still does not load the selected item in the child list.
sorry I missed it before... you need to add filter and populate list onload before you can set the value.... so add:
WA_FilterAndPopulateSubList(ProductCateg oryList_WAJA,MM_findObj('Class'),MM_findObj('Produ ctCategoryID'),0,0,false,': ')
Thank you!! That was it! Works like a charm. I appreciate the help and most importantly the quick response as usual.
Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.
These out-of-the-box solutions provide you proven, tested applications that can be up and running now. Build a store, a gallery, or a web-based email solution.