Tagged: 

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #86146
    Michaela
    Participant

    Hi Mahesh,
    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,
    Michaela

    #86179
    Mahesh
    Participant

    Hi @micha,

    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.

    Regards,
    Mahesh

    #86205
    Michaela
    Participant

    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?

    #86208
    Mahesh
    Participant

    Hi @micha,

    The name and value attribute is to assign name and specific value for that input option.

    Regards,
    Mahesh

    #86216
    Michaela
    Participant

    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.

    #86223
    Mahesh
    Participant

    Hi @micha,

    Okay to make you clear, lets take an example:
    You have two inputs, say color and fruits:
    Colors you like
    1. Red
    2. Blue
    3. Green
    4. Black

    Fruits you like
    1. Orange
    2. Banana
    3. Apple
    4. Grape

    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.

    Regards,
    Mahesh

    #86225
    Michaela
    Participant

    Okay, thanks for the clarification. I guess it makes sense for forms, but not if you don’t have any 😉

    #86278
    Mahesh
    Participant

    Hi @micha,

    Yes indeed. 🙂
    Have a nice day!

    Regards,
    Mahesh

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Radio button or check box’ is closed to new replies.