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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥15 cmd cl 0x000007b
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
    • ¥500 火焰左右视图、视差(基于双目相机)
    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统