Forums

Pass variables from 1 custom element to the next

andysmith 07 Jun, 2011
I'm trying to create a series of select lists based on the contents of a database. The first looks up level 1 items say fruit, the next box looks up level 2 items say apples bananas. Is there an easy way to set the query on the second lookup box to be the value of the first lookup ie fruit?
GreyHead 07 Jun, 2011
Hi andysmith,

There is one simpe solution here using JavaScript to hide blocks of options. This is fine if the lists are reasonably short.

There is an Ajax Solution (eritten for ChronoForms v4 but adapatable to CFv4) in the document you can buy for a few $ here.

Bob .
andysmith 09 Jun, 2011
I've now implemented the AJAX option and it seems to be getting stuck, the first dropdown seems to work fine but it is not calling any code to make changes to the second dropdown. Are there any changes required for the JRequest::getString('sid', '', 'get'); as it is now listed as a public static function.

I would be grateful for any pointers in the right direction.
GreyHead 09 Jun, 2011
Hi andysmith,

I think that JRequest still works OK. Hard to tell what else might be the problem without seeing the form and the code.

By all means email or PM me the site URL and a SuperAdmin login and I'll take a quick look.

Bob
andysmith 09 Jun, 2011
I've PM'd the details to you.
GreyHead 10 Jun, 2011
Hi andysmith,

Nothing received yet :-(

Bob
andysmith 10 Jun, 2011
Sent it again via the email option.
GreyHead 10 Jun, 2011
Hi andysmith,

This is now working more or less OK. Most of what I did was tidying up and updating the code to work wit MooTools v1.3 (There's a guide to that version here )

Note: The bug fix in that post still needs to be implemented to hide the extra strapline that ChronoForms is adding.

The main change was to move the Ajax code from the OnLoad event to a new Ajax Event so that it can be accessed independently of the form code.

Bob
This topic is locked and no more replies can be posted.