[Resolved] radio input, different css for each selection
This thread is resolved. Here is a description of the problem and solution.
Problem:
The issue here that the customer wanted to dynamically allocate classes to a div based on the checkbox that the user selected when creating his/her post from CRED.
Solution:
To do this you will need to create a selectable type of Custom Field such as Checkboxes, Radio Buttons or Select Field.
From here you will need to set the value of each of the field to a class name that you would like.
Then when the user selects the option they want then you will need to assign that class to the div by doing this.
The customer also provided a guide here @https://toolset.com/forums/topic/radio-input-different-css-for-each-selection/page/2/#post-612157
This support ticket is created 6 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
I have a user form with radio field: hidden link
the radio field basically loads the different background for each choice made.
you see: hidden link hidden link
I also need to change the position of "photo" - "creature name" - "dedication",
according to the choice of the radio field.
The only way is to load a different CSS for each selection. how can I do ? or do you have other ideas?
What you can do is to store the css classes in the radio field. Then when you are loading the page for the post you will pass that types code into the css class option like this.
<div class="[types field='radio-field'][/types]"
Then you can specify the css information so it will only load that css base on the class selected.
Please let me know if this helps.
Thanks,
Shane
So I went in and created a field called Layout Choice which is a radio button that allows the user to select a color, this is just to show you what I'm referring to.
Secondly I added this field to your form see screenshot.
After which I updated the layout to add the field in the form <div class="[types field='radio-field'][/types]"></div>
See Screenshot
Finally The code is now rendered on the frontend with the appropriate class that was set in the options. See Screenshot
So if the user selects red in the form the class will be red.
Please let me know if this clears things up for you.
Shane I saw what you did.
I do not understand however how this can position the elements: "titolo-creatura" - "prima-foto" - "dedica", etc. in a different way from every choice of the radio field
Example: from the radio field a user chooses the "red" class.
this class (red) must make sure that the "creature title" is positioned
top: 10px; - "prima-foto": top: 40px;
yellow class must make sure that the "titolo-creatura" is positioned
top: 40px; - "prima-foto": top: 60px;
the positioning is done by Css in the CSS and JS layout:
To do the changes for a specific class you will need to write the css like this.
Lets say you want the changes to only apply when the user selects red. Using the .prima-foto class as an example this code below will only apply if the user selects red
If you check the html of any post that has that option selected you will see that they have the stone_1 class assigned to it. This is what I believe you want, setting a custom class based on the option.