Thursday, November 25, 2010

Re: AJAX Chain Reaction - Multiple Divs.

Good to hear!

At the moment, you initially only display one <select> list, and then
based on that, you show other <select> lists. But what you want, is to
show all the lists always, and just change the options available, the
<label> of the lists, and potentially hide some lists. Does that sound
accurate?

I think I may have confused myself a little here as well!

Each time a select box is changed, cakePHP will detect which step it requires from the user next. I will give you two examples:

Example 1 - Selecting a vertical blind (just the louvres, 89mm wide in Lino Ivory from the Fabric Box collection)

Step 1) Type of Blind: Vertical
Step 2) Fabric Book: Fabric Box
Step 3) Specification: Vanes Only
Step 4) Louvre Width: 89mm
Step 5) Fabric: Lino Ivory

Example 2 - Selecting a perfect fit pleated blind in an Aura White fabric.

Step 1) Type of Blind: Pleated
Step 2) Specification: Perfect Fit
Step 3) Fabric: Aura White

This is why I decided to show and hide select boxes.

If I selected the first example of a vertical blind all the way to Fabric, but then I changed my mind and changed "Type of Blind" to "Pleated", all the other 4 steps need to disappear and step 2 then becomes "Specification". What I have been asked to do now this system is working as intended... to make it even easier for the user! Heh :)

I need to define a default path for each type of blind - i.e. the most common product selection - or the product selection which comes at no extra charge to the user.

A vertical blind would be automatically selected like the following when you specify "Type of Blind" as vertical:

1. Vertical
2. Blindtex Seasons
3. Full Vertical
4. 89mm
5. "Please Select"


The approach you would need to take I think would be one where instead
of making an AJAX request and the response being an HTML snippet which
you insert into a <div>, you need to make an AJAX request with the
response being JSON data, which you supply to a function which
constructs the <option>s for you and attaches them to the appropriate
<select> element. This way, your <select> elements could be defined
statically, and hence appear on the form from the first page load.

I have heard of JSON but frustratingly I haven't used it yet, it is on my todo list so why not start now?
 

Does it sound like I'm on the right track? If so, I can provide you
with a small example on how to achieve this.

Would you be as kind?

Here's some example code (it's not too pretty, but it does the job)
http://pastie.org/private/swxfzq8yirsbnu9yjzrrg

As you can see, I don't just need to generate the select lists, but I also need to execute the controller actions one after another.

P.S. the drop down boxes were provided for me to use, I will find out if they are proprietary or not.

Kind Regards
 Stephen


Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: