Rumah  >  Soal Jawab  >  teks badan

php - 请大神进来看看,修改后checkbox多选项不能保存。

 $output .= '<input id="' . esc_attr( $id ) . '" class="checkbox hui-input" type="checkbox" name="' . esc_attr( $name ) . '" ' . $checked . ' />
<label for="' . esc_attr( $id ) . '">' . esc_html( $label ) . '</label>';

第一段是原始代码。

$output .= '<label class="checkbox primary" for="' . esc_attr($id) . '">
                <input id="' . esc_attr($id).'" class="checkbox hui-input" type="checkbox" data-toggle="radio" value="" name="' . esc_attr($name).'" ' . $checked . '/>' . esc_html($label).'
                </label>';

第二段是修改后的代码,修改后的checkbox不能保存,我这是Wordpress后台的设置项。请问哪里出问题了?
如果有人能解答,真是感激不尽,这问题困扰了我很久了,春节前开发的,就是因为这个问题到现在都没解决。

PHP中文网PHP中文网2750 hari yang lalu300

membalas semua(2)saya akan balas

  • 阿神

    阿神2017-04-10 15:30:56

    多选的话, name 属性应该是这样才PHP才可以接受所有选中的项的值:

    <input type="checkbox" name="sex[]" value="1"> 
    <input type="checkbox" name="sex[]" value="0"> 
    

    balas
    0
  • 巴扎黑

    巴扎黑2017-04-10 15:30:56

    @__FresHmaN 真的很谢谢你,今天凌晨发现问题是在于 value="" ,这个为空,所以服务器就接受不到数据了,我删掉了value标签就好了。

    balas
    0
  • Batalbalas