Jump to content

Radio buttons not serialized under NAME

Go to solution Solved by Perry M.,

I'm not sure how you're defining your radio buttons, but you normally use a `value` attribute to specify what is submitted with the form:

 

<input type="radio" id="choice1" name="my-radio-buttons" value="email" />
<input type="radio" id="choice2" name="my-radio-buttons" value="phone" />
<input type="radio" id="choice3" name="my-radio-buttons" value="mail" />

 

In this scenario, if the second button was selected, the value `phone` would be submitted for `my-radio-buttons`.

 

Are you able to share more code in terms of your radio buttons? I'm not sure what this means by itself:

 

"flexRadioDefault":"1"

So I have a form, using some radio buttons for mutually exclusive selection. Radio buttons are great as I can simplify code (basically not write any code for it) as they do exclusivity automatically. All is great except field serialization. I send off my form data, it saves the radio fields under a single name by which they are all grouped under, I can't give each a unique name otherwise their radio function stops working.

 

Problem is, if I have 3 choices the only serialized data might be: 

"flexRadioDefault":"1"

...good luck me finding out which one of the 3 was selected.

 

My only brainstorm solution is to actually send off the button ID inside the "value" which I could reference later? Instead of "1" here could be "flexRadioDefault":"ID1 to 3." For documentation and form loading. What would be the best way to sort this out? Am I good to try and figure out how to cross reference which radio button was selected with sending the ID inside value or am I overcomplicating things not aware that there's an easy solution?

Desktop: Ryzen 7 5800X3D - Kraken X62 Rev 2 - STRIX X470-I - 3600MHz 32GB Kingston Fury - 250GB 970 Evo boot - 2x 500GB 860 Evo - 1TB P3 - 4TB HDD - RX6800 - RMx 750 W 80+ Gold - Manta - Silent Wings Pro 4's enjoyer

SetupZowie XL2740 27.0" 240hz - Roccat Burt Pro Corsair K70 LUX browns - PC38X - Mackie CR5X's

Current build on PCPartPicker

 

Link to comment
Share on other sites

Link to post
Share on other sites

I'm not sure how you're defining your radio buttons, but you normally use a `value` attribute to specify what is submitted with the form:

 

<input type="radio" id="choice1" name="my-radio-buttons" value="email" />
<input type="radio" id="choice2" name="my-radio-buttons" value="phone" />
<input type="radio" id="choice3" name="my-radio-buttons" value="mail" />

 

In this scenario, if the second button was selected, the value `phone` would be submitted for `my-radio-buttons`.

 

Are you able to share more code in terms of your radio buttons? I'm not sure what this means by itself:

 

"flexRadioDefault":"1"
Link to comment
Share on other sites

Link to post
Share on other sites

54 minutes ago, Perry M. said:

I'm not sure how you're defining your radio buttons, but you normally use a `value` attribute to specify what is submitted with the form:

 

<input type="radio" id="choice1" name="my-radio-buttons" value="email" />
<input type="radio" id="choice2" name="my-radio-buttons" value="phone" />
<input type="radio" id="choice3" name="my-radio-buttons" value="mail" />

 

In this scenario, if the second button was selected, the value `phone` would be submitted for `my-radio-buttons`.

 

Are you able to share more code in terms of your radio buttons? I'm not sure what this means by itself:

 

"flexRadioDefault":"1"

That's exactly the thing, I wished it would send data as 

"choice3":"mail"

not

"my-radio-buttons":"mail"

as it would save me a lot of time and headache making a new function just to sort out save data and yea, as said above if I have to make a new function it'll probs have to identify the correct radio with the value, this case being "mail."

 

Just hoping there's a way to not do that :DD

Desktop: Ryzen 7 5800X3D - Kraken X62 Rev 2 - STRIX X470-I - 3600MHz 32GB Kingston Fury - 250GB 970 Evo boot - 2x 500GB 860 Evo - 1TB P3 - 4TB HDD - RX6800 - RMx 750 W 80+ Gold - Manta - Silent Wings Pro 4's enjoyer

SetupZowie XL2740 27.0" 240hz - Roccat Burt Pro Corsair K70 LUX browns - PC38X - Mackie CR5X's

Current build on PCPartPicker

 

Link to comment
Share on other sites

Link to post
Share on other sites

4 hours ago, venomtail said:

That's exactly the thing, I wished it would send data as 

"choice3":"mail"

not

"my-radio-buttons":"mail"

as it would save me a lot of time and headache making a new function just to sort out save data and yea

A radio button is to limit the users to a choice to expected values of your choosing, Which checkbox the user choose should have no bearing on your backend code for processing the form as you know the potential values the user is likely to submit. The radio button name submitted shouldn't be a problem.

Link to comment
Share on other sites

Link to post
Share on other sites

16 hours ago, venomtail said:

That's exactly the thing, I wished it would send data as 

"choice3":"mail"

not

"my-radio-buttons":"mail"

 

 

But, you can - if you simply change the `name` attribute of the inputs.

 

You haven't shared the HTML code for your inputs.. if you do that we might be able to point you in the right direction. All we have now is a JSON-looking property which doesn't indicate that you're actually writing HTML.

Link to comment
Share on other sites

Link to post
Share on other sites

Goofy brain, my bad guys sadKEK - Discord Emoji

 

Everything theoretically is correct as it should be, was correct, overlooked that I had values themselves wrong this whole time, basically as listed above being 

<input type="radio" id="choice1" name="my-radio-buttons" value="choice1" />
<input type="radio" id="choice2" name="my-radio-buttons" value="choice1" />
<input type="radio" id="choice3" name="my-radio-buttons" value="choice1" />

I had my compiler working correctly, using value to look for matching ID, just since ID was not only the same for all, it was something like "choce1" so of course there won't even be a match so defaults to last entry. Deadass something so simple caught me out again 🫠

 

oof, I'll not recover for a month...

Desktop: Ryzen 7 5800X3D - Kraken X62 Rev 2 - STRIX X470-I - 3600MHz 32GB Kingston Fury - 250GB 970 Evo boot - 2x 500GB 860 Evo - 1TB P3 - 4TB HDD - RX6800 - RMx 750 W 80+ Gold - Manta - Silent Wings Pro 4's enjoyer

SetupZowie XL2740 27.0" 240hz - Roccat Burt Pro Corsair K70 LUX browns - PC38X - Mackie CR5X's

Current build on PCPartPicker

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×