setLabel

TonyBenedetti

Hobbyist Programmer & Fabrik Fan
I have the following code in both the "on load" and "on click" events of a radio button group. The value and label are identical for each button (e.g., "Month", "Quarter", etc.) -- adding "_raw" doesn't make any difference.

The element whose label I am trying to change is a CascadingDropDown. The CDD itself is also based on the button group and that is working fine, but the label simply refuses to change.

It has to be a RDB ("Real Dumb Blunder") on my part but I'll be darned if I can find it. Does anyone out there have any idea what's going wrong?

JavaScript:
var form = Fabrik.getBlock('form_23');
var table = 'gn_event___';
var types = table + 'end_division_of_year_types';
var choices = table + 'end_division_of_year_choices';
var chosen = form.elements.get(types).getValue();
form.elements.get(choices).setLabel(chosen);
 
I don't usually help with custom coding in free support, but if you point me at the page I'll take q cuik look.

-- hugh
 
Thanks for your generous offer, Hugh. But your setLabel works perfectly under normal circumstances. I placed similar code in another (simpler) form -- with the element fullnames "changed to protect the innocent". It works great -- "just as advertised".

But my troublesome form is not simple.
  • I have my own version of the bootstrap_tabs template with the default.php amended to use a suggestion you gave a while ago. That suggestion allows the first group in a form not to be "tabbed" (see near the bottom of the "Multiple Secundary (sic) Forms in Tabs" thread). That works great !
  • I have a button group on the "un-tabbed" group that allows for show/hide of 5 combinations (start only; start/end; start/duration; duration/end; & duration only) of the 3 "tabbed" groups (start, duration & end). That's working fine!
  • The setLabel is used on the start and end groups. I've eliminated two "suspects". 1) setLabel doesn't work on simple "fields" -- I thought it might be that it might be that a CDD was the object of the operation; 2) setLabel doesn't work on any groups of the form -- I thought it might be failing only on a "tabbed" group. Oh well ...
Given all that, I don't want you to waste any time on a conundrum that may poke up its ugly head on only one form in the galaxy. I'll try my luck tracking down the problem -- even down into the deep recesses of the Fabrik PHP code. Who knows? I may even learn something. I once coded mainframe computer simulation models for IBM -- although that was before object orientation made the IT world "easier".

If I don't find something in a "reasonable" time (or if I begin to have thoughts of harming myself or my equipment), I'll circle back on bended knee and ask for your help. And even then, changing that label isn't "mission critical" ... it would just be sorta slick.

Remember I'm now just a "hobbyist programmer" so nothing is "mission critical"! Although I expect to become fabulously wealthy when Google buys my concept for a gazillion dollars.

Thanks again,
Tony
 
Looks like I've dug a pretty deep hole for myself with the altered default.php. It appears that the "on click" JS isn't invoked at all. I replaced the code with the simple single line "window.alert ('yikes');" -- no go!

Must be something in the way I implemented Hugh's suggested "don't tab the 1st group" mod. Or perhaps the problem lies with my show/hide code for the tabbed groups.

I'll keep digging. Who knows what I'll find down there.
 
Well, it turns out it was a Real Dumb Blunder ... but I now have things working!

I had an error in some JS in an "on load" elsewhere -- same form, different tabbed group -- and out of sight, out of mind! Apparently, that error stopped any/all JS on the form from running.

Now back to making new problems for myself.
 
Basically, if you see any Javascript errors thrown when the page loads (use something like Dev Tools in Chrome), there's a better than even chance all Javascript running on page load will get short circuited at that point. So the first thing to do whenever you gave JS issues is make sure the page is loading cleanly, no errors.

Sent from my HTC6545LVW using Tapatalk
 
Thanks once again, Hugh! Yours is, as always, sage advice. Others listening in on this thread would be well advised to take heed.

But, unfortunately, most of the time I'm working "blind" -- using Chrome on an Android tablet. Only when I used the deskside Windows machine at home over the weekend did I get to see the problem with Dev Tools on a "grownup" Chrome. Android Chrome doesn't have anything like Dev Tools ... sigh.:(
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top