Default a field after an earlier field is selected - JS?

kdiamond

Member
I have two tables. One with a list of events and another with a list of post-event reports.

The post-event reports adopt a few fields of the event table, like location, date/time, and client.

In the report table, I need the report form to capture the client products that were given out (among many other fields). Meaning I know the client already, but not until the event name is selected. Once I know the client, I can then present CCD list of that clients' products (that part works perfectly).

My question is - do I need javascript to default the client so that the products CCD works once they select the event name? I am under the impression right now that a normal php default cannot be done after page load without javascript. Any help appreciated - I did review the form javascript samples and none seem to fit this defaulting scenario.

Thanks in advance.
 
I'm not entirely sure of your setup from that description, but it might be possible with daisy chained CDD's.

On the report form, is the 'events' a join element?

Is there only one 'client' per event?

Give us more details ...

-- hugh
 
Thanks Hugh- gladly.

List of events:

  1. Event ID
  2. Event name/code
  3. Location - name only - no ID
  4. Client - name only - no ID
  5. Date/Time
  6. many other fields irrelevant

List of Event reports (one event report per event- one to one) I could make them in the same table, where the event report info is just added on to the event list....

  1. Event name code (this is what the user has to find/select and kicks off the defaults)
  2. Location ('forced' from above list) I need this shown so that the user sees it and hopefully realizes they might have selected the wrong job name - that is a common problem we have)
  3. date/time (defaults from above list but can be changed)
  4. current User entering the report (got this part no problem)
  5. Client (preferred forced from list above)
  6. check box list of the clients products (this works fine once the client is selected- but I would prefer they have the client put in for them)
  7. many other entered details irrelevant.
Hope that helps- I can enable the superuser for you if you want to get in to look.
On the daisy-chained CCD- I like the idea but can't figure out the daisy chain logic.
I tried it and maybe my logic is off, but either the CCD's would but spin back and forth when the page is loaded, assuming I made some kind of loop....
OR the client field simply would not change. Product CCD would still work once a client was manually selected.
Any help appreciated... Also - any data deisgn guidance welcome as well - I'm not married to this data model, except for the event list - that comes from elsewhere so it needs to stay untouched and BTW - is loaded regularly with CSV uploads... might make combining these two areas in one table kinda tricky.
Thank you
 
I agree - but when I set that up I could not get it to 'react' to the field change. It would only react to Form Load.

I do have another table with a list of clients. Perhaps I join the events table with that table by name, then maybe that would allow an ID lookup. Unless a double jump/join would just cause more confusion....

Would a custom javascript on the event name field work?
 
yes - I set the trigger element to the event name, and when I change the event name it does not react. As in, working mapping or not, it doesn't 'confirm' that I want to autoload the form. Only works when its set to form load.
 
Hmm, no, the "trigger" element shouldn't be the same as the "Field to Observe". That would cause us to get our JS event handling undies in a bundle.

Default behavior (without setting a trigger) is to fire off the search when the "Observed" element blurs (cursor leaves it) for a text element, or changes (for a dropdown, etc). If you specify a trigger, which would usually be a button element, but could technically be anything, we ignore events on the "observed" element, and fire the plugin when the trigger is clicked. if you set the trigger to the observed, I have a feeling that would kind of cancel each other out.

I had a quick look at the code, and I think just using a field as the observed should work, with no need for a trigger. And I'm pretty sure I've done it before, for a client. I also have a feeling I made the autofill field also be a auto-complete join to the same table as the autofill ... but my memory is a little hazy ... I just remember fixing things so if the auto-select join resuted in a single selection, it would trigger the autofill ... hmmm ..

If you want to set that autofill up again, don't specify a trigger, post a screenie of your settings, and give me a link to the front end page, I'll have a quick look to see if there's some obvious reason why it's not working.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top