[thelist] Coldfusion: getting javascript variables

.jeff jeff at members.evolt.org
Tue Jan 8 19:06:27 CST 2002


ted,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: ted serbinski
>
> I want to be able to retrieve the data in a JavaScript
> array and put this into a list or struct in ColdFusion.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

how is this array being created in the first place?

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> Now what is the best way to do this?
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

you really only have 3 ways -- each more difficult than the one before.  the
first two involve changing pages.  the last one involves getting the values
to the server without leaving the page.

1)  turn the array values into a string and pass
    them as a url variable.

2)  turn the array values into a string, stuff them
    into a form field, and submit the form.

3)  turn the array values into a string and pass
    them as a url variable in an image preload
    that references a coldfusion script, rather
    than an actual image.  or, use a hidden iframe
    and target the request there.  or, use javascript
    to write to a cookie, then use an image swap or
    iframe to trigger the cf server to read the
    cookie.  or, target the posting of the form in
    number 2 above to a hidden iframe.  what you do
    with the response from the server is up to you.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> One way I thought of was taking my array, turning it
> into a long string, and sending the data like this:
>   menu.cfm?link1=home&link2=here&link3=ect
>
> Would this work? Any better ideas?
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

sure, that'd work fine, but you'll end up creating really long urls.  your
goal, should you decide that using the url is the best way to do this (i
would agree), is to try to keep the urls as short as possible.  you would do
this by eliminating as much redundant information as possible.  for example,
use a single url variable, create a list of values as a single string, and
pass that as the value to the single variable.  so, instead of the link you
have above, you'd end up with:

menu.cfm?links=home,here,etc

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> What I need these variables for is to generate a list
> of links, upon depending on which link you click, a
> different set of sub links appear.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

and these sublinks are generated from what?  any reason you can't pass a
single identifier to the "sub" page and have it figure out the sublinks at
that time?

good luck,

.jeff

http://evolt.org/
jeff at members.evolt.org
http://members.evolt.org/jeff/






More information about the thelist mailing list