0

I use this code when create input box for post meta box:

<input type="text" name="<?php echo $name; ?>" id="x" value="<?php echo $value; ?>" />

Now I need to handle radio box which has 2 inputs with the same name:

<input type="radio" name="option" id="option-current" value="0" />
<input type="radio" name="option" id="option-custom" value="1" />

If use echo $name; and echo $value with radio type, post meta will have 2 value for one key, that makes the radio selection lost meaning.

How to get correct result from the radio type?

1

Radio buttons should have the same name with different values if you want to group them together. I'd call them something that isn't option and not use the ID.

http://www.w3schools.com/html/html_forms.asp

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.