If anyone would like to see the final result, it's available here (I
used tinyURL so this doesn't end up on Google...):

http://preview.tinyurl.com/foodfinder

On 19 Mar, 16:40, Matt <guitarroman...@gmail.com> wrote:
> Thanks Colin - I read your post after I painstakingly wrote a function
> to do this manually, eg, adding each ID to an array, removing them if
> the user deselects a checkbox, then sending it. My corresponding php
> was really messy too in order to cater for all the different
> possibilities. After a bit of debugging with your code (a few brackets
> out of place I think) I have it working - thank you! When it's all
> done I might post a blog entry detailing the overview for the whole
> thing... not being able to find such a tutorial for what I thought was
> quite a basic tool spurred me on to write my own.
>
> Matt
>
> On 19 Mar, 09:53, ColinFine <colin.f...@pace.com> wrote:
>
> > On Mar 18, 2:21 pm, Chris Sansom <ch...@highway57.co.uk> wrote:> At 05:51 
> > -0700 18/3/09, Matt wrote:
>
> > > >So, like, keep track of what options the user has selected and add
> > > >these to an array or something that I can then use to send a $_GET
> > > >request to my script?
>
> > > Specifically, use them to build a query string (and you can use GET
> > > or POST - that's up to you).
>
> > 'Keep track of' implies some sort of remembering and building your
> > query string bit by bit. You don't need to: you just make getData read
> > all the current boxes. Something like
>
> > --Cuisine--
> > Italian: <input class = 'parameter' id = 'cuisine-23' type="checkbox">
>
> > --Price Range--
> > £0 - £10: <input class = 'parameter' id = 'price-6' type="checkbox">
> > ...
> > <script type='text/javascript'>
>
> > function updateData()
> > {
> >   var parameters = ();
> >   $$('input.parameter').each(function(element) {
> >      if (element.checked) {
> >         parameters.push(element.id.replace(/-/, '=');
> >      })
> >    // parameters is now an array containing elements like 'cuisine=2',
> > 'cuisine=23', 'price=7',
> >    // so you use parameters.join('?') in building your query string
>
> >   ..
>
> > }
>
> > $$('input.parameter').invoke('observe', 'click', updateData);
>
> > </script>
>
> > (All untested).
>
> > I've used Element.observe rather than level 0 event handlers.
>
> > Colin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to