[Pro] databas

I would like to create a dropdown list of the 58 California counties and when a county is selected I would like Freeway to display various agencies of that county, its address, ph#, etc.

Any suggestions?


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

You could do this in JavaScript pretty simply. The data aren’t going
to change all that often, are they? I mean, you don’t need a client
interface, security for that interface, and a MySQL table to store it
so it can be updated frequently, right?

Get a good text editor, like the fabulous (and FREE) TextWrangler from http://barebones.com
and type up a basic sample of the data. Just do two or three of the
counties to start, so you can see how this will work for you.

I would put this in a Hash format:

A hash is a structure of key/value pairs, and it can be nested to
almost any degree. What I’ve set up above has an outer layer of keys
for the counties, each holding a value that is itself a hash of agency
names to their respective addresses. The curly braces define a hash,
the colon separates the key from the value, and the comma separates
key/value pairs from one another within the hash.

And then you can get at the elements of that hash using the Prototype
library. You could build your picker in JavaScript by iterating over
the keys of your hash:

By adding a listener to your picker, you could catch the ‘change’
event and display your data for that county in another HTML box on
your page.

Let me know if this seems do-able on your end, and I’ll post the rest
of the code.

Walter

On Jan 23, 2011, at 8:20 PM, ScottSimons wrote:

I would like to create a dropdown list of the 58 California counties
and when a county is selected I would like Freeway to display
various agencies of that county, its address, ph#, etc.

Any suggestions?


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

On Jan 23, 2011, at 8:56 PM, Walter Lee Davis wrote:

You could do this in JavaScript pretty simply. The data aren’t going to change all that often, are they? I mean, you don’t need a client interface, security for that interface, and a MySQL table to store it so it can be updated frequently, right?
yes that is correct, although line items do change periodically

Get a good text editor, like the fabulous (and FREE) TextWrangler from http://barebones.com and type up a basic sample of the data. Just do two or three of the counties to start, so you can see how this will work for you.
I have that

I would put this in a Hash format:

https://gist.github.com/792835

A hash is a structure of key/value pairs, and it can be nested to almost any degree. What I’ve set up above has an outer layer of keys for the counties, each holding a value that is itself a hash of agency names to their respective addresses. The curly braces define a hash, the colon separates the key from the value, and the comma separates key/value pairs from one another within the hash.

And then you can get at the elements of that hash using the Prototype library. You could build your picker in JavaScript by iterating over the keys of your hash:

gist:792846 · GitHub

By adding a listener to your picker, you could catch the ‘change’ event and display your data for that county in another HTML box on your page.

Let me know if this seems do-able on your end, and I’ll post the rest of the code.

how would it be displayed?

thank you

Scott

Walter

On Jan 23, 2011, at 8:20 PM, ScottSimons wrote:

I would like to create a dropdown list of the 58 California counties and when a county is selected I would like Freeway to display various agencies of that county, its address, ph#, etc.

Any suggestions?


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

It would replace whatever was currently showing in a box on the page. Basically, you would draw an HTML box on the page, put some instructions in it like “choose a county to see the office info” and when the picker is changed, the content of that box would update with the correct info.

Walter


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Here’s a quick example at jsbin (so you can click the little edit
widget in the top-right corner and see what’s behind the curtain)

http://jsbin.com/edidi4/4

Walter

On Jan 24, 2011, at 12:51 AM, waltd wrote:

It would replace whatever was currently showing in a box on the
page. Basically, you would draw an HTML box on the page, put some
instructions in it like “choose a county to see the office info” and
when the picker is changed, the content of that box would update
with the correct info.

Walter


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

man, thats magic!, is there anyway to import/export from a database or spreadhseet?

On Jan 23, 2011, at 10:27 PM, Walter Lee Davis wrote:

Here’s a quick example at jsbin (so you can click the little edit widget in the top-right corner and see what’s behind the curtain)

http://jsbin.com/edidi4/4

Walter

On Jan 24, 2011, at 12:51 AM, waltd wrote:

It would replace whatever was currently showing in a box on the page. Basically, you would draw an HTML box on the page, put some instructions in it like “choose a county to see the office info” and when the picker is changed, the content of that box would update with the correct info.

Walter


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

If you have PHP 5 handy, you can convert an associative array (which
in PHP is the equivalent data structure to a JavaScript Hash) into a
hash using the json_encode() function. You have to have a recent
version of PHP (5.2 or greater) to have this function available.

So if you can coerce your database content into an array like this:

$counties = array('Alameda' => array('Parks and Recreation' =>  

‘address’,
‘Public Works’ => ‘address’),
//etc…
);

Then running json_encode($counties) would give you the same string
value that I assigned to the JavaScript variable ‘data’ in my example
without you needing to type it all out long-hand.

Many different ways to skin this cat, so if you already have the
content in a database like MySQL, you could also just run a query to
build the picker and use an Ajax callback to return the latest data
each time that picker is changed.

The advantage to the hash is that all the data is in the page, so the
lookup is nearly instantaneous. But for a large dataset, that
advantage might be partially negated by the overall page size when it
includes the entire database in JavaScript notation.

If you can tell me some more about how you have this data stored
currently, and how often it needs to change, I can recommend some
other approaches.

Walter

On Jan 24, 2011, at 9:33 AM, Scott Simons wrote:

man, thats magic!, is there anyway to import/export from a database
or spreadhseet?


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options