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

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Format Dynamic Dropdown Output

Thread began 8/04/2010 7:04 pm by madmatmail408476 | Last modified 8/13/2010 5:34 pm by Eric Mittman | 1126 views | 10 replies |

madmatmail408476

Format Dynamic Dropdown Output

I have a simple parent - child dynamic drop down working but would like to format the result of the child dropdown.

It returns a list of dates but displays them in the MySQL format of "2010-10-09". How can I get it to return "Monday 9th October 2010", for instance?

The dates are also displayed in decreasing rather than ascending order - how do I amend this?

Thank you.

Sign in to reply to this post

Eric Mittman

You can format the date in a php page with the php date function. You would need to apply this to the recordset value for the date that is referenced in the 'create dynamic array' server behavior. Here is a link to the page that explains more about the date function:

php.net/manual/en/function.date.php

To get the records to show in ascending order you will need to adjust the recordset that is used in the 'create dynamic array' server behavior. You will need to edit this recordset and set the order by, select the column, then set to ascending.

If you have any trouble with the date formatting post back withe the file in question and let me know the name of the date column and I can show you where this needs to be added.

Sign in to reply to this post

madmatmail408476

Format Date

Hi, I was able to change the sort order no problem so thanks.

I can see what you mean about applying a date format as I have done it before in simpler cases but I cannot see where to apply it in this case.

I attach the code for the page:

(The recordset is called child and the date field is called surgery_date in veterinary_surgeon_table)

Thank you.

Attached Files
page.txt.zip
Sign in to reply to this post

Eric Mittman

The line of code that you will need to edit is on line 256, here is the line:

php:
echo "WAJA[".$n."][".$m."][1] = "."'".WA_DD_Replace($row_child["surgery_date"])."'".";\n";



You will need to apply the date formatting function around the recordset value on this line:

php:
date("your format string", $row_child["surgery_date"])
Sign in to reply to this post

madmatmail408476

Format Date

Hi, thanks for the reply. I am having difficulty working out what this line of code is doing so am unsure of the correct syntax to use in the line you recommended.

If I just add the date format string as below it returns all dates of 01/01/1970 (which is wrong). When I try and change the syntax I mostly get a 'Non well formed numeric value encountered' message.

echo "WAJA[".$n."][".$m."][1] = "."'".WA_DD_Replace(date('dS F Y', $row_child["surgery_date"]))."'".";\n";

Thanks.

Sign in to reply to this post

Eric Mittman

It looks like you have added this just fine, but it is missing a crucial part that I forgot to show in my example. The problem is that the date formatting function formats a time stamp value, it will not directly re-format a date value. So you will need to add in one more part to make the current date a timestamp like this:

php:
echo "WAJA[".$n."][".$m."][1] = "."'".WA_DD_Replace(date('dS F Y', strtotime($row_child["surgery_date"])))."'".";\n";



Sorry about that, it slipped my mind that you were working with a formated date value already. Here is a link to the php page for the strtotime function, this along with the date and mktime are very powerful tools for editing dates and times.

php.net/manual/en/function.strtotime.php

Sign in to reply to this post

madmatmail408476

Off Topic

Thanks a lot, that works just fine now.

Sign in to reply to this post

madmatmail408476

Follow on Question

Hi Eric. I have a follow on question. Please let me know if I should post it elsewhere but I though as you already know the code on this page...

I am trying to create a grandchild after the date drop down (which was the child). The grandchild drop down is using the same table as the child one but returning the vet name (s) for that date.

I cannot seem to get it to work.

Firstly, when I created the second Dynamic Array (for the child/grandchild relationship) the previous Dynamic Array (parent/child) disappeared from the Server Behaviours panel - I can still see it in the code but can no longer edit it using the panel because it is not there.

The situation now is that the parent (branch name) and child (date) work fine but the Select vet drop down remains blank and does not load any data - any ideas?

Thank you

Attached Files
Grandchild.txt.zip
Sign in to reply to this post

Eric Mittman

It seems that you have the recordset setup correctly for this but when I view select lists and the populate list from array behaviors I see an issue. It looks like you are defaulting the child select list to get it's values from the child recordset. You should only be setting the parent select list to get it's values from the recordset, the other two lists should be populated from the populate list from array behaviors that you have.

You should apply the first populate list from array behavior on the parent list, this will populate the child list with the values you specify. Then for the grandchild list you will apply the populate list from array to the child list. So long as the id values match as a foreign key you should get the grandchild list to populate with the correct values based on the selection in the child list.

I also noticed that you had a populate list from array behavior applied to a td on the page, if you want the lists to be populated based on the selection of the previous list you should only be applying this behavior to the parent and child select lists.

Sign in to reply to this post

madmatmail408476

Confused

Hi Eric.

I have been following your instructions. The child select list no longer get's its values from the child recordset. I have also removed the Populate List from Array that was applied to a <tr>.

I have set the rest up following the instructions and the grandchild list now comes up with a long list of blanks (instead of vets names). I have checked and the database does have relevant data - any reason why it would come up with blanks?

Your comment about Foreign Keys also puzzled me. I am using PHPMyAdmin and have never set up Foreign Keys on any of my tables and yet my first Parent - Child Dynamic Drop Downs worked fine. Are Foreign Keys something I should be setting up manually in my database for these drop downs to work?

Thanks

Sign in to reply to this post
loading

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