When using radio with form attribute Topic is solved

Talk about code development, features, specific bugs, enhancements, patches, and similar things.
Forum rules
Please keep everything here strictly on-topic.
This board is meant for Pale Moon source code development related subjects only like code snippets, patches, specific bugs, git, the repositories, etc.

This is not for tech support! Please do not post tech support questions in the "Development" board!
Please make sure not to use this board for support questions. Please post issues with specific websites, extensions, etc. in the relevant boards for those topics.

Please keep things on-topic as this forum will be used for reference for Pale Moon development. Expect topics that aren't relevant as such to be moved or deleted.
rerere

When using radio with form attribute

Unread post by rerere » 2019-12-02, 02:46

When using both of radio with form attribute and radio without form attribute,
value of radio with form attribute is affected by radio without form attribute.
But, sending value dose not include radio without form attribute.

Code: Select all

<label>1
<input form="a" type="radio" name="radio" value="1" checked id="radio1">
</label>
<label>2
<input form="a" type="radio" name="radio" value="2">
</label>

<form id="a" method='post'>
<label>3
<input form="" type="radio" name="radio" value="3">
</label>
<input type='submit'>
</form>
https://jsfiddle.net/htf7z3px/

1, 2: radio with form attribute
3: radio without form attribute

When click "3", "1" radio became unchecked.
But, posted value does not include key of "radio".

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35474
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: When using radio with form attribute

Unread post by Moonchild » 2019-12-02, 07:37

This is not a bug in the browser. If you explicitly clear the form name then the input will not be part of the form (and thus not submitted).
Any radio with the same name attrribute will be part of the same radio group, per definition.

Please go back to school on how to use radio controls.
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

rerere

Re: When using radio with form attribute

Unread post by rerere » 2019-12-02, 10:18

The same radio group?
Although two elements was checked after click "3" and "1"?
https://imgur.com/9APT2gA

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35474
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: When using radio with form attribute

Unread post by Moonchild » 2019-12-02, 12:38

Yes the same radio group. You give it the same name, then it's the same group.
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

rerere

Re: When using radio with form attribute

Unread post by rerere » 2019-12-03, 00:59

Once the radio group is created, selecting any radio button in that group automatically deselects any other selected radio button in the same group.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35474
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: When using radio with form attribute

Unread post by Moonchild » 2019-12-03, 10:58

"unless you use undefined behavior"
Look at your code. What form does the control in question belong to? Is it part of form "a"?

Just clean up your code. make radios part of the named group and be unambiguous about what form the controls belong to, and you're good.
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

rerere

Re: When using radio with form attribute

Unread post by rerere » 2019-12-04, 08:59

OK, this browser is implemented with not specification-based but behavior-based.
Thank you.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35474
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: When using radio with form attribute

Unread post by Moonchild » 2019-12-04, 09:40

rerere wrote:
2019-12-04, 08:59
OK, this browser is implemented with not specification-based but behavior-based.
Thank you.
If it's a spec compliance issue, then please point me to the relevant spec that addresses this situation.
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

Locked