-
- 8 Posts
Hi
I am just working my way through learning ModX and have created a custom input page in the manager using Form Customization. I would like to add a bit of javascript to hide/show some of the form fields depending what is set in some radio buttons.
regClientScript seems to be what is needed but I can't figure out where to add it.
Any suggestions gratefully received.
Thanks
Pete
-
- 24,544 Posts
Either regClientScript() or regClientStartupScript() (if you want it in the head section) will do it, most likely in a plugin attached to OnDocFormPrerender. You should be aware, though, that much of the Create/Edit Resource panel is created on the fly by modExt/ExtJS JavaScript and the parts you want to modify may not be there yet when your JS code is running.
-
- 8 Posts
Thanks Bob will give it a try later in the day.
-
- 8 Posts
Hi Bob
I could not get regClientScript() to do anything (no javascript or script tags were loaded), however regClientStartupScript() worked just fine. Then I discovered the nightmare of the manager layout I am clearly going to need to get my head round EXT before I do much more. It's odd I can get a radio button by its id with javascript getElemendById wrapped in a Ext.onReady function, typeof tells me I have an object, but then I can do nothing with it (add an event, get a value, see if it's checked) as anything I try and do tells me it's null. Plain input fields all work normally.
Next step is to read up on EXT.
Regards
Pete
-
- 5,888 Posts
Perhaps there are simpler ways to get done, what you are trying.
May be custom-TV-input-types are what you are looking for.
What are you trying to create?
-
- 8 Posts
Hi Bruno17
This is really just me trying to get an in depth understanding of Modx. I have been very impressed with what you can do with Modx - in fact I have not yet found anything that cannot be achieved. As a learning exercise I have been replicating an existing site built in php/mysql and found it could be done with out any php coding. Next step was to add some snippets and make it more efficient. Again that was not a problem. Now I am at the next stage of trying to make a manager input screen more user friendly. In this example there are 7 fields of which 3 only need filling in depending on the setting of a radio button. The radio button selection controls the chunk which is selected to build the final output. OK I can leave the 3 fields displayed and ignore them if the user fills them in, but it would be much better to only show them if they were required.
If I can get my head round EXT then it should be straight forward.
Regards
Pete
-
- 5,888 Posts
perhaps this can give you some ideas for handling TVs depending of other TVs:
https://github.com/Bruno17/DynamicDropdownTV
-
- 8 Posts
Bruno
Thanks you I will look with interest.
Pete
-
- 24,544 Posts
regClientScript() puts the JS above the closing body tag, so maybe you didn't scroll down far enough to see it.