doujiepin5547 2014-02-01 21:43
浏览 55

如何使用单选按钮在多维数组中保存默认值

I'm working on a form creation tool, the Select field contains a section where you can create new options and mark one as default.

Here is an example: http://screencast.com/t/AvyVqh3pv

My array of saved attributes looks like this right now:

1 => 
    array (size=5)
      'title' => string 'Title' (length=5)
      'type' => string 'select' (length=6)
      'required' => string '0' (length=1)
      'options' => 
        array (size=7)
          0 => string '1' (length=1)
          1 => string '4' (length=1)
          3 => string '6' (length=1)
          4 => string '7' (length=1)
          5 => string '8' (length=1)
          6 => string '9' (length=1)
          7 => string '10' (length=2)
      'default_option' => string '10' (length=1)

I'm using jQuery to change the radio button value when respective text input value is changed. This works fine but I'd like to have this feature working even if javascript is not enabled.

I'm working with the WordPress Settings API so my options are limited here I guess, this is the HTML used for each one of the Text Input + Radio Button rows:

<div class="fusion_booking_form_field_option_holder">
    <input type="radio" name="fusion_booking_form_field[1][default_option]" value="1">
    <input option_id="0" type="text" name="fusion_booking_form_field[1][options][0]" class="fub_form_field_options" value="1">
    <div class="fub_form_field_options_remove">Remove Option</div>
</div>
<div class="fusion_booking_form_field_option_holder">
    <input type="radio" name="fusion_booking_form_field[2][default_option]" value="1">
    <input option_id="1" type="text" name="fusion_booking_form_field[2][options][0]" class="fub_form_field_options" value="2">
    <div class="fub_form_field_options_remove">Remove Option</div>
</div>

Any ideas on how I can save the selected default option in a way that I can easily check it when the page is reloaded is appreciated.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
    • ¥88 实在没有想法,需要个思路
    • ¥15 MATLAB报错输入参数太多
    • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
    • ¥15 有赏,i卡绘世画不出
    • ¥15 如何用stata画出文献中常见的安慰剂检验图
    • ¥15 c语言链表结构体数据插入
    • ¥40 使用MATLAB解答线性代数问题
    • ¥15 COCOS的问题COCOS的问题
    • ¥15 FPGA-SRIO初始化失败