0

I am using radio boxes to save values into an array, the issue I am having is trying to automatically check the checkbox for the corresponding value after the page is refresh or whatever

I have tried the following;

<h3 style="margin-bottom: 0px;">Floating</h3></br>
<input type="radio" name="lu_ban_data[noticeType]" value="multi"<?php echo ('multi' == get_option( 'noticeType' ))? 'checked="checked"':''; ?> /></input>

<h3 style="margin-bottom: 0px;">Floating</h3></br>
<input type="radio" name="lu_ban_data[noticeType]" value="floating"<?php echo ('floating' == get_option( 'noticeType' ))? 'checked="checked"':''; ?> /></input>

The value is being saved when I click either one array (size=6) 'noticeType' => string 'multi' (length=5) but the corresponding checkbox isnt being checked.

value

Anyone help?

checkbox

output markup

<div style="margin: 10px;">
                        <h3 style="margin-bottom: 0px;">Multiple</h3></br>
                        <input type="radio" name="lu_ban_data[noticeType]" value="multi" /></input>
                        <h3 style="margin-bottom: 0px;">Floating</h3></br>
                        <input type="radio" name="lu_ban_data[noticeType]" value="floating" /></input>
                    </div>

the "checked" is not being printed

David Garcia
  • 3,056
  • 18
  • 55
  • 90

2 Answers2

0

You say its in an array? how are you getting that array?

To use get_option() at some point you have to use update_option()

Try echo get_option( 'noticeType' ) and see what is stored in the wordpress option.

0

I made it work like so;

value="multi" <?php $value = get_option('lu_ban_data'); checked( $value['noticeType'], 'multi' ); ?>
David Garcia
  • 3,056
  • 18
  • 55
  • 90