close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

How to select specific row from database as initially selected in child menu

Thread began 5/14/2013 8:49 am by Roxana | Last modified 5/14/2013 9:14 pm by Roxana | 1285 views | 8 replies |

Roxana

How to select specific row from database as initially selected in child menu

Have been brewing over this for days.

Two menus let the user choose version and size of a product. With onload (body tag) and onChange (select tag) the child menu only shows available sizes.

I would like to preselect ($row_rssizedefault['size_id']=='4') as initial value in the child menu.

This is the code of the parent menu:

<select class="<?php echo $tmpElementClassVersion; ?> name="SelectVersion" id="SelectVersion" onchange="WA_FilterAndPopulateSubList(rssize_WAJA,MM_findObj('SelectVersion'),MM_findObj('SelectSize'),0,0,false,': ');showprice()">
<?php
do {
?>
<option value="<?php echo $row_rsversion['version_id']?>"<?php if (!(strcmp($row_rsversion['version_id'], $row_rsversion['version']))) {echo "selected=\"selected\"";} ?>><?php echo $row_rsversion['version_compound']?></option>
<?php
} while ($row_rsversion = mysql_fetch_assoc($rsversion));
$rows = mysql_num_rows($rsversion);
if($rows > 0) {
mysql_data_seek($rsversion, 0);
$row_rsversion = mysql_fetch_assoc($rsversion);
}
?>
</select>



This is the code of the child 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>



So far I have managed to preselect the desired value by replacing the selected attribute with this:

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


but only if I delete this:

onload="WA_FilterAndPopulateSubList(rssize_WAJA,MM_findObj('SelectVersion'),MM_findObj('SelectSize'),0,0,false,': ')"


When I delete the onload code though, the size menu includes all sizes, also a size not available for the version.

Sign in to reply to this post

Roxana

Having the body tag like this:

<body onload="showprice()">



and the select attribute like this:

<?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.

Is it possible to modify the body tag, so that the size menu will populate according to the version menu without resetting the size to "XS"?

<body onload="WA_FilterAndPopulateSubList(rssize_WAJA,MM_findObj('SelectVersion'),MM_findObj('SelectSize'),0,0,false,': '); showprice()">
Sign in to reply to this post

Jason ByrnesWebAssist

in the body onload event add another behavior.

add the WA Dynamic DropDowns -> Set Selected in list behavior.

Set the target list to the child list, for the value enter 4.

Sign in to reply to this post

Roxana

I uninstalled and reinstalled DataBridge, because I didn't see where to enter a value (sorry, took a while).

Now I cannot choose a different table for the child menu. I am guessing this is, because the size table should be part of the recordset rsversion?

This is rsversion:

$varproductid_rsversion = "-1";
if (isset($_GET['recordID'])) {
$varproductid_rsversion = $_GET['recordID'];
}
$varlanguageID_rsversion = "1";
if (isset($_SESSION['languageID'])) {
$varlanguageID_rsversion = $_SESSION['languageID'];
}
mysql_select_db($database_connSegufix, $connSegufix);
$query_rsversion = sprintf("SELECT DISTINCT tblversion.version_id, tblversion.version, tblversion.version_description, tblversion.version_compound FROM tblprice INNER JOIN tblversion ON tblversion.version_id = tblprice.version_id WHERE tblprice.product_id = %s AND tblversion.language_id = %s", GetSQLValueString($varproductid_rsversion, "int"),GetSQLValueString($varlanguageID_rsversion, "int"));
$rsversion = mysql_query($query_rsversion, $connSegufix) or die(mysql_error());
$row_rsversion = mysql_fetch_assoc($rsversion);
$totalRows_rsversion = mysql_num_rows($rsversion);



Where am I going wrong?

Sign in to reply to this post

Jason ByrnesWebAssist

I dont follow, please provide more details.

Sign in to reply to this post

Roxana

I am not sure I understood your instructions correctly. When trying to add a server behaviour I get the window as in the attachment.

There is no "Set Selected" in list behavior.

So I couldn't "Set the target list to the child list, for the value enter 4."

I am completely at a loss.

Sign in to reply to this post

Roxana

The problem is, that the code to populate the size menu also resets the size to the first record onChange or onload.

WA_FilterAndPopulateSubList(rssize_WAJA,MM_findObj('SelectVersion'),MM_findObj('SelectSize'),0,0,false,': ')



Can the code be modified to just populate the size menu but not set a value?

Sign in to reply to this post

Jason ByrnesWebAssist

the act of populating the menu is what is changing the selection.

The Set Selection behavior is not a server behavior, it is a behavior, it is accessed in the same way the populate list from array behavior is accessed, from the Behaviors tab.


open the behaviors panel (not Server Behaviors) click the plus button, select WebAssist -> WA Dynamic DropDowns -> Set Selected in list behavior.

Sign in to reply to this post

Roxana

Now I understand.

The resulting code in the body tag looks like this:

WA_setSelectionsInChildList(MM_findObj('SelectSize'),4)



With this code the size selection (child menu) will be set to size M, but only if I delete the behaviour that populates the size selection with the available sizes. Unfortunately showing the available sizes is more important than being able to preselect the most popular size M.

For future versions of DataBridge it would be nice, if the selection in the child menu can be set while at the same time it is possible to populated the child menu with the available options only. Also when the user makes a choice in the child menu first and then decides to change the selection in the parent menu, that the child menu is not reset, but stays at the previous user selection.

Sorry, for my English. I hope I was able to explain the problem.

And thank you, Jason, for helping me.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

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.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...