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

Dynamic drop down list using validation show if?

Thread began 4/10/2013 1:32 am by rikaG_510 | Last modified 4/13/2013 3:21 am by rikaG_510 | 765 views | 9 replies |

rikaG_510

Conditional drop down list using validation show if?

Hi Jason,

I need to make a conditional drop down list, but not sure how to make this happen.

I made these tables in my database.
[ CountryCategory ]
id country
1 England
2 Wales
3 Scotland
4 Ireland

[CountryList]
id CountryCategory shops
1 1 shope#1
2 1 shope#2
3 2 shope#3
4 2 shope#4


And form area with 5 drop down menu for;

[CountryCategory]
[shops in England]
[shops in Wales]
[shops in Scotland]
[shops in Ireland]


It should work like this;
When a country name is chosen from a list populated with CountryCategory;
another dorp-down list appears depending on which country is chosen;
e.g)
If 1 (England) is selected from [CountryCategory], a drop-down list of [shops in England] will appear, and so on.

What's the best way to do this?

I read "Getting Start with Validation Tool" hoping to help me to understand, but the logic of validation is confusing me… you purposely make errors so you get to see/use "show if"?? Also, I'm confused with "Validation show if" and "show region utility".

Could you briefly tell me the steps to make this happen so I'll know where to start?

Thank you for your help,
Rika

Sign in to reply to this post

Jason ByrnesWebAssist

What you are trying to do has nothing to do with validation.

for this you would use the Dynamic Drop Downs tool.

Create a recordset to return the Countries

Create a parent list on the page, and use the countries recordset to populate it. use the id column as the value and the country column as the label

Create another recordset for the CountryList table.

On the server behaviors panel, Click the plus button and select webassist -> Dynamic Drop Downs -> Create Dynamic Array.

Select to use the CountryList recordset. use the CountryCategory column as the Parent ID, the id column as the child ID and the shops column as the child lable.

Add the child select list to the page.

in design view, select the parent list, then open the behaviors panel, click the plus button and select webassist -> Dynamic Drop Downs -> Populate list from array.

use the CountryList dynamic array, select the main list as the parent list and the second list as the child list, make sure the behavior is applied to the onchange even.

Sign in to reply to this post

rikaG_510

Oh...okay. No wonder whatever I was reading didn't connect to what I wanted to do!

Thank you Jason, for detailed guidance. I will give it a try.

Rika

Sign in to reply to this post

rikaG_510

Jason,

I followed through your guidance.
It's not working, so I must be doing something wrong...
At the moment the child list appears as blank before/after the parent list is chosen.
(It shows contents alright without DD applied).

I attached my code for this. Could you take a look?

Thank you so much!
Rika

Attached Files
dd not working.txt
Sign in to reply to this post

Jason ByrnesWebAssist

please post a link where i can see the problem to investigate.

Sign in to reply to this post

rikaG_510

This morning I gave it a try from scratch, and this time it's working!

I made a comparison to before and after file, and found out that I made a strange line break in the middle of php code, and php code for "if ($row_list)" was placed to left floating area where menu lists were on the right floating area. Fixing these made the before file work as well.

Anyhow, thank you for your help!

Sign in to reply to this post

rikaG_510

Jason,

Drop down lists are working great now. I'm facing another issue.
How do I pass the value of child list to confim page?
Also at the moment parent list (country) is passing id numbers, is there a way to pass the country name?

I am using ::::: value="<?php echo $_SESSION['name01']; ?>" :::::for text field to pass values and to be able to go back and force between a form page and confirm page, and eventually store the data to database.


:::::: Parent list (country) ::::::::

<select name="country" onchange="WA_FilterAndPopulateSubList(list_WAJA,MM_findObj('country'),MM_findObj('list'),0,0,false,': ')">
<option value="">Choose a country</option>
<?php
do {
?>
<option value="<?php echo $row_country['id']?>"><?php echo $row_country['RewardCountryCategory']?>
</option>
<?php
} while ($row_country = mysql_fetch_assoc($country));
$rows = mysql_num_rows($country);
if($rows > 0) {
mysql_data_seek($country, 0);
$row_country = mysql_fetch_assoc($country);
}
?>
</select>



:::::: Chile list (shops) ::::::::

<select name="list">
<option value=" "></option>
<?php
do {
?>
<option value="<?php echo $row_list['id']?>"><?php echo $row_list['RewardCountryName']?>
</option>

<?php
} while ($row_list = mysql_fetch_assoc($list));
$rows = mysql_num_rows($list);
if($rows > 0) {
mysql_data_seek($list, 0);
$row_list = mysql_fetch_assoc($list);
}
?>
</select>

Sign in to reply to this post

Jason ByrnesWebAssist

the value from the child list passes the same way as the parent value.

the parent has to pass the ID in order for the child list to work.

on the page that the form posts to, add a recordset to look up the ID that is passed and show the country name.

Sign in to reply to this post

rikaG_510

Hi Jason,

Thanks, it's all working now.

Your words sometimes sound like cleaver teachings of Yoda… I kind of struggle first trying to figure out what it really means, then the moment sparks, everything makes sense after that!

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