【问题标题】:How to change my array to a input field如何将我的数组更改为输入字段
【发布时间】:2015-11-17 12:34:04
【问题描述】:

这是我的数组。

$m3 = array
(
'2' => '2',
'4' => '4',
'6' => '6',
'9' => '9',
'14' => '14',
'18' => '18',
'20' => '20',
'other' => 'other'

);

现在,当我选择“其他”时,将显示一个输入字段。

    <?=$form->input('Car/m3', array('name' => "other_interest", 'style' => "display:none", 'class' => 'inputText', 'label' => false));?>

这是显示输入框的脚本

JQUERY

jQuery(document).ready(function () {
    jQuery("#CarM3").change(function () {
        if (jQuery(this).val() === 'other') {
            jQuery('input[name=other_interest]').show();
        } else {
            jQuery('input[name=other_interest]').hide();
        }
    });
});

我想要的是,当我按下保存时,输入字段中的文本将显示在我的页面上,而不是“其他”。

【问题讨论】:

  • 重复? 3 hours ago
  • 您可能想在您的问题中加入更多背景信息……例如; $form 是什么?
  • 那么决定页面上显示内容的代码在哪里?

标签: jquery arrays


【解决方案1】:

试试:

$('form').submit(function(){
  $('body').html($('input[name="other_interest"]').val());
});

【讨论】:

    猜你喜欢
    • 2018-07-14
    • 2020-06-22
    • 1970-01-01
    • 2019-02-08
    • 2019-07-10
    • 2012-07-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多