EasyCFM.COM ColdFusion Forums / Coding Help! / Need help with an array

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: Need help with an array -- page: 1 2

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

Vidikron
02-09-2009 @ 1:29 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 103
Joined: May 2007

OK, I'm trying to use the calendar found here:  Link

I've put that calendar onto a form, but I can't seem to grab the dates selected by the user.  This is some information on how the calendar is supposedly sending the dates:  Link

If I use the "get" method for the form the dates appear in the URL like this:

calendardates%5B15%5D=2009-02-23&calendardates%5B16%5D=2009-02-24&calendardates%5B17%5D=2009-02-25


So there appears to be an array being passed in the URL.  The problem is I have not idea how to work with it.  I've tried calling to URL.calendardates, calendardates, and form.calendardates and each time I get an error stating calendardates is undefined.  So clearly I'm clueless on working with arrays in an URL.

But ultimately I need to be using the post method anyway.  I was only using "get" so I could actually see that the dates were being passed.  The author of the calendar says that if you can see the dates using get, they are being passed using post as well.  I've tried both methods and get "undefined" errors each time.  So what am I doing wrong?

This message was edited by Vidikron on 2-9-09 @ 1:29 PM

Vidikron
02-11-2009 @ 9:21 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 103
Joined: May 2007

Anyone? Do I need to provide more info?

Webmaster
02-11-2009 @ 12:39 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Administrator
Posts: 4542
Joined: Jan 2002

Can you change to a POST and then dump the form struct?


<CFDUMP VAR="#FORM#" />


Once you do that; then show that (screenshot) on here so we can get a better idea of what to reference...

Let me know.

Pablo Varando
Senior Application Architect
EasyCFM.COM, LLC.

904.483.1457 \\ mobile
webmaster@easycfm.com \\email

\m/ (>.<) \m/
--- rock on ---

dlackey
02-11-2009 @ 12:40 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 935
Joined: Jun 2007

What an excellent use of Ajax!  I'll look into this and see if I can provide some assistance...

Cheers,
Chip

dlackey
02-11-2009 @ 1:11 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 935
Joined: Jun 2007

Well, after reading the documentation and working through the examples, I need to know if you are using the popup calendar to populate a textbox or the flat calendar to select a date, or if you are using a flat calendar to selects several dates.  From the demo/example I was working through, the textbox did not have name; therefore, that value would not be passed via post/get.  Adding a name to that box DOES submit the value.  I'm still working through the flat calendars.  Those are tiny bit more complex.

Cheers,
Chip

dlackey
02-11-2009 @ 1:16 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 935
Joined: Jun 2007

Nevermind, I figured out which calendar you wanted to use.  :doh:  

Cheers,
Chip

dlackey
02-11-2009 @ 3:05 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 935
Joined: Jun 2007

<cfloop index="thefield" list="#urldecode(cgi.QUERY_STRING)#" delimiters="&">
    <cfset fields="#thefield#">
    <cfoutput>#fields#</cfoutput><br>
</cfloop>

See if this will help you out to get the url values.

Cheers,
Chip

Vidikron
02-11-2009 @ 3:28 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 103
Joined: May 2007

OK, here's the requested screenshot:


I think I just need help dealing with arrays.  According to that cfdump the array is definitely being submitted.  I looked at the array functions on Livedocs and tried a couple of things, but I get "undefined" errors each time.  For example, I tried just converting the array to a list by doing this:

<cfset myList = ArrayToList(calendardates, ",")>

But that simply resulted in an "Variable CALENDARDATES is undefined" error.

Webmaster
02-11-2009 @ 4:40 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Administrator
Posts: 4542
Joined: Jan 2002

Looking at the screen shot; that is not really an array.. its just a structure.

You can use the example above for URL submit; if you want to use POST the you would do this:

<cfloop collection="#form#" item="key">
  Element Name: #key#<br />
  Element Value: #form[key]#<br />
</cfloop>

That should get you the values.

Pablo Varando
Senior Application Architect
EasyCFM.COM, LLC.

904.483.1457 \\ mobile
webmaster@easycfm.com \\email

\m/ (>.<) \m/
--- rock on ---

Vidikron
02-11-2009 @ 5:11 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 103
Joined: May 2007

Is there a way alter that code so that it just outputs the values for any "calendardates" element? Maybe with a CFIF and regular expression?

PAGE: 1 2

Website Designed and Developed by Pablo Varando.