- This topic has 7 replies, 2 voices, and was last updated 7 years, 1 month ago by Mahesh.
February 24, 2016 at 2:14 am #86146
I was wondering how I can include radio buttons or checkboxes in my text on a normal page? For example, when I have a packlist, I’d like to have these in front of each item.
Also, if you have a code for this: when you select it, does it stay selected for a while (how long?) through cookies or does it get deselected as soon as you leave the page?
Thanks for your help,
MichaelaFebruary 24, 2016 at 12:11 pm #86179
If you just want the checkbox and radio button (html), you can go to content text tab then add the following:
<label>Checkbox</label> <input name="checkbox" type="checkbox" value="a" />A <input name="checkbox" type="checkbox" value="b" />B <label>Radio button</label> <input name="radio" type="radio" value="c" />C <input name="radio" type="radio" value="d" />D
But html won’t transfer state or save value, it will only remain selected until you refresh the page.
I you want to save and access value, you will have to use plugins eg: Contact Form 7.
MaheshFebruary 24, 2016 at 3:22 pm #86205
Great, thanks a lot. I’ll use the code as installing too many plugins slows my website down.
Just one more question for clarification: Why do you need to use “name” and “value”? The radio button or checkboz also appears without these properties?February 24, 2016 at 3:56 pm #86208
The name and value attribute is to assign name and specific value for that input option.
MaheshFebruary 24, 2016 at 4:58 pm #86216
I understand, but what does it do? Why can’t I just use the following code?:
<input type=”checkbox” />A
This will give me the same visible result on the frontend.February 24, 2016 at 5:21 pm #86223
Okay to make you clear, lets take an example:
You have two inputs, say color and fruits:
Colors you like
Fruits you like
Then we would have used the following HTML code
<input type="checkbox name="color" value="red" /> <input type="checkbox name="color" value="blue" />... <input type="checkbox name="fruit" value="orange" /> <input type="checkbox name="fruit" value="banana" />..
Name attribute will make multiple options for one option. i.e. it make sure that red, green, blue and yellow are options for color.
Similarly, value is to make sure which options are selected, if no value is given, how do we know which options were selected for the inputs.
This is very important while working with forms.
Same goes with radio buttons.
Hope you understand.
MaheshFebruary 24, 2016 at 5:34 pm #86225
Okay, thanks for the clarification. I guess it makes sense for forms, but not if you don’t have any 😉February 25, 2016 at 9:39 am #86278
- The topic ‘Radio button or check box’ is closed to new replies.