close ad
WARNING PC USERS: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

using DD with preselected values

Thread began 10/04/2009 1:20 pm by barbara224891 | Last modified 10/15/2009 2:29 pm by Jason Byrnes | 3070 views | 8 replies |

barbara224891

using DD with preselected values

I've got a parent list (organizations) and a child list(contacts). When the page loads, I would like it to show a particular value in the parent list as selected, that value depending on a recordset value. I tried selecting the parent dropdown and applying the set selected in list behavior, but that didn't work. I realized one reason it didn't work is that it was initially applied onchange, just like the populate list from array behavior. I tried changing it to onload, but still no luck.

If I weren't using dynamic dropdowns, I'd do this with the bind to dynamic source button in the properties window, but that seems not to work.

here's the code for the parent list:
<select name="orgID" id="orgID" onchange="WA_FilterAndPopulateSubList(contacts_WAJA,MM_findObj('orgID'),MM_findObj('contact'),1,0,false,': ')" onload="WA_setSelectionsInChildList(MM_findObj('orgID'),<?php echo $row_project['agency']; ?>)">
<option value="" <?php if (!(strcmp("", $row_project['agency']))) {echo "selected=\"selected\"";} ?>>-- select --</option>
<?php
do {
?>
<option value="<?php echo $row_agencies['orgID']?>"<?php if (!(strcmp($row_agencies['orgID'], $row_project['agency']))) {echo "selected=\"selected\"";} ?>><?php echo $row_agencies['name']?></option>
<?php
} while ($row_agencies = mysql_fetch_assoc($agencies));

?>
</select>

I'd like the child list to also prepopulate according to the recordset, but until I can get the parent working, that one seems unlikely.

Thanks for your help.

Sign in to reply to this post

Jason ByrnesWebAssist

apply the Dynaminc Dropdowns set selected in list behavior to the onLoad event of the body tag.

Sign in to reply to this post

barbara224891

OK, in order to do that, I had to detach the page from the template. What's a better way to do that? I tried adding an editable region inside the body tag, but DW wouldn't allow that. I tried adding an editable region which contained the body tag, but then DW became unable to display anything in the body of the document.

Anyway, I did detach it from the template and add the onload event to the body tag for selecting the first dropdown and that works. Now I need to get the child dropdown to show as selected. The child dropdown works if the user selects the organization, but if the organization is selected by the onload event, the child dropdown shows as unpopulated and it's not only not selected, it's not selectable.

I tried adding a second onload behavior to populate the child list, but it doesn't do anything, presumably because there's no array selected.

Here's the latest version of my body tag:
<body <? if (isset($_GET['ID'])) { ?> onload="WA_setSelectionsInChildList(MM_findObj('orgID'),<?php echo $row_project['agency']; ?>)" <? } ?> <? if (isset($_GET['ID'])) { ?>onload="WA_FilterAndPopulateSubList(contacts_WAJA,MM_findObj('orgID'),MM_findObj('contact'),1,0,false,': ')" onload="WA_setSelectionsInChildList(MM_findObj('contact'),<?php echo $row_project['contact']; ?>)" <? } ?> >

Perhaps if I tweaked the code on the FilterandPopulateSubList parameters it would work, but since I'm not sure what those parameters refer to, I haven't ventured there.

Thanks, barbara

Sign in to reply to this post

barbara224891

calendar_add_notemplate.php?ID=81#

This child dropdown is really not working correctly. If the user selects the parent, the child table at first appears to offer the correct choices. However, it's not actually possible to select any of them. When you try to view page source, it doesn't show any items in the child select menu. The parent list is the agency, the child is the contact.

Please help.

Sign in to reply to this post

Jason ByrnesWebAssist

The only way to add the onlaod event is to detach the page form the temlate unfortunately.


the onLoad code has some spaces in it that are causing javascript errors:

php:
<body <? if (isset($_GET['ID'])) { ?> onload="WA_setSelectionsInChildList(MM_findObj('or gID'),<?php echo $row_project['agency']; ?>)" <? } ?> <? if (isset($_GET['ID'])) { ?>onload="WA_FilterAndPopulateSubList(contacts_WAJ A,MM_findObj('orgID'),MM_findObj('contact'),1,0,fa lse,': ')" onload="WA_setSelectionsInChildList(MM_findObj('co ntact'),<?php echo $row_project['contact']; ?>)" <? } ?> >




needs to be changed to:

php:
<body <? if (isset($_GET['ID'])) { ?> onload="WA_setSelectionsInChildList(MM_findObj('orgID'),<?php echo $row_project['agency']; ?>)" <? } ?> <? if (isset($_GET['ID'])) { ?>onload="WA_FilterAndPopulateSubList(contacts_WAJA,MM_findObj('orgID'),MM_findObj('contact'),1,0,fa lse,': ')" onload="WA_setSelectionsInChildList(MM_findObj('contact'),<?php echo $row_project['contact']; ?>)" <? } ?> >
Sign in to reply to this post

barbara224891

That was a good catch. I have fixed the space typos and added some line breaks to make the html lines shorter so they don't get recreated spontaneously, which is how they got there in the first place.

I'm still having 2 problems with this page:
1. If there is a project passed in the URL, the parent field selects properly, but the child dropdown does not populate. If there is no ID passed in the URL, or if the user selects an agency, the child dropdown will populate.

2. When the child dropdown populates, it's not actually possible to select any of the choices. Reviewing the page's source code shows the child dropdown as empty.

I've tinkered a lot, trying different things, so I'm including the body tag here again as it currently stands:

<body <? if (isset($_GET['ID'])) { ?> onload="WA_setSelectionsInChildList(MM_findObj('orgID'),<?php echo $row_project['agency']; ?>)" <? } ?>
<? if (isset($row_project['agency'])) { ?>onload="WA_FilterAndPopulateSubList(contacts_WAJA,MM_findObj(<? echo $row_project['agency']; ?>),MM_findObj('contact'),1,0,false,': ')"
onload="WA_setSelectionsInChildList(MM_findObj('contact'),<?php echo $row_project['contact']; ?>)" <? } ?>
>

In trying to understand what's going on, I also made a much simpler page with the essential features I'm working on here. It's at scratch.php?ID=81

With the simpler version, problem 1 still exists, but problem 2 does not. I haven't been able to understand why it allows selection of the child while the real page doesn't.

Thanks, barbara

Sign in to reply to this post

Jason ByrnesWebAssist

I think this is caused by having multiple onloads in the body tag.

try using this for the body tag:

php:
<body onload="<? if (isset($_GET['ID'])) { ?> WA_setSelectionsInChildList(MM_findObj('orgID'),<?php echo $row_project['agency']; ?>);<? } ?><? if (isset($row_project['agency'])) { ?>WA_FilterAndPopulateSubList(contacts_WAJA,MM_findObj(<? echo $row_project['agency']; ?>),MM_findObj('contact'),1,0,false,': ');WA_setSelectionsInChildList(MM_findObj('contact'),<?php echo $row_project['contact']; ?>) <? } ?>">
Sign in to reply to this post

barbara224891

Tried that. Didn't change either problem 1 or problem 2.

Still troubled by the difference between the two pages, the simpler one working slightly better. That might be significant.

Sign in to reply to this post

Jason ByrnesWebAssist

OK, I think i see the problem now, the simple page did help, thoug you have one problem on that page.

The child list is named "contactID" on the simple page and "contact" on the other one.


I believe this for the body tag should do the trick:

php:
<body onload="<? if (isset($_GET['ID'])) { ?> WA_setSelectionsInChildList(MM_findObj('orgID'),<?php echo $row_project['agency']; ?>);<? } ?><? if (isset($row_project['agency'])) { ?>WA_FilterAndPopulateSubList(contacts_WAJA,MM_findObj('orgID'),MM_findObj('contact'),1,0,false,': ');WA_setSelectionsInChildList(MM_findObj('contact'),<?php echo $row_project['contact']; ?>) <? } ?>">
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...