You are not logged in.

#1 2025-05-10 19:39:46

lo7777799
Member
Registered: 2023-07-25
Posts: 57

HTML-problems with option-fields in form

good evening all, smile

here is my problem ...

here is my text ...

<form>
    <input type="radio" id="likeradio" value="like"><label>mir gefällts</label>
    <input type="radio" id="likeradio" value="dislike"><label>mir gefällts nicht.</label>
    <input type="radio" id="stimmung" value="happy"><label>ich bin gut drauf</label>
    <input type="radio" id="stimmung" value="unhappy"><label>ich bin nicht gut drauf</label>
    <input type="checkbox" id="dauer" value="geduldig"><label>ich bin schon lange hier</label>
    <input type="checkbox" id="zeit" value="spaet"><label>es ist schon spät</label>
</form>

my problem is, that the user can choose all 4 radio-boxes. the checkboxes does that, what the checkboxes should do.

but i can choose all 4 radio-buttons, when i visit my site.

i want, that the website visitor only can choose 1 "likeradio"-button and only 1 "stimmung"-button... so i want, that the website visitor can only choose 2 of all 4 radio buttons.

what is wrong in my html5-code?

Last edited by lo7777799 (2025-05-10 19:41:31)

Offline

#2 2025-05-10 21:01:52

seth
Member
Registered: 2012-09-03
Posts: 63,637

Re: HTML-problems with option-fields in form

https://www.w3schools.com/tags/att_input_type_radio.asp - see the "name" attribute.
Another source you might be interested in is https://wiki.selfhtml.org/wiki/SELFHTML

Ok, and technically this isn't "programming" nor "scripting" - it's "markup" tongue

Offline

#3 2025-05-11 11:52:25

lo7777799
Member
Registered: 2023-07-25
Posts: 57

Re: HTML-problems with option-fields in form

ok thanks very much, i found the error...

it is not necessary to give "mir gefaellts" and "mir gefaellts nicht" the same "id". they can have different "id"s...

it is necessary to give "mir gefaellts" and "mir gefaellts nicht" the same attribute at "name"... and the html command "name" must be written into the text.

<input type="radio" id="likeradio" name="likeq" value="like"><label>mir gefällts</label>
    <input type="radio" id="likeradio" name="likeq" value="dislike"><label>mir gefällts nicht.</label>

in this code, "like" and "dislike" have the same attribute at "name", it is "name="likeq", the q i have given the name is short for question, like-question... now it works like it should...

problem is solved now

Last edited by lo7777799 (2025-05-11 11:54:46)

Offline

#4 2025-05-11 11:56:35

lo7777799
Member
Registered: 2023-07-25
Posts: 57

Re: HTML-problems with option-fields in form

seth wrote:

Ok, and technically this isn't "programming" nor "scripting" - it's "markup" tongue

should this post be in "artwork" section of this forum?

Offline

#5 2025-05-11 12:01:38

seth
Member
Registered: 2012-09-03
Posts: 63,637

Re: HTML-problems with option-fields in form

\o/
Please always remember to mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks.

Offline

Board footer

Powered by FluxBB