【问题标题】:jQuery Input value not returned when submit提交时不返回jQuery输入值
【发布时间】:2017-10-02 10:58:03
【问题描述】:

[菜鸟问题] 我正在使用 Wordpress 的联系表格 7。我有 2 个输入,我必须为事件返回 post_title 和 price:

if (window.location.href.indexOf("event") > -1) {
  var titre = $('.entry-title').text();
  var prix = $('.ai1ec-cost .ai1ec-field-value').text();

  $('.ghost input').prop('disabled', true);
  $('.ghost input').attr('value', titre);
  $('.ghost input').val(titre);

  $('.ghostPrice input').prop('disabled', true);
  $('.ghostPrice input').val(prix);

}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form action="/event/pause-cafe-des-parents/?instance_id=35#wpcf7-f1623-o1" method="post" class="wpcf7-form" novalidate="novalidate">
  <label class="ghost"> Nom de l'événement<br>
    <span class="wpcf7-form-control-wrap evenement">
      <input name="evenement" value="la pause-café" size="40" class="wpcf7-form-control wpcf7-text" aria-invalid="false" disabled="" type="text">
    </span>
  </label>
  <label class="ghostPrice"> Prix de l'événement<br>
    <i>Les modalités de paiements seront présents dans l'e-mail de confirmation</i><br>
    <span class="wpcf7-form-control-wrap price">
      <input name="price" value="" size="40" class="wpcf7-form-control wpcf7-text" aria-invalid="false" disabled="" type="text">
    </span>
  </label>
  <p>
     <input value="Envoyer" class="wpcf7-form-control wpcf7-submit" type="submit"><span class="ajax-loader"></span>
  </p>
</form>

我的输入正确返回了我的值,但是当我提交表单时,该值没有返回。

如果我输入我的输入(如普通形式),我的值将被返回。

有什么想法吗?

【问题讨论】:

  • ghostPrice,在哪里?
  • 问题中缺少一些细节,例如您正在使用的输入以及您提交表单的位置。
  • @Roamer-1888 幽灵价格就像另一个标签 :) (相同但只是类更改)
  • @bhansa 已编辑

标签: jquery html forms input


【解决方案1】:

我刚刚删除了“禁用”并添加了“隐藏”,它就可以工作了。

【讨论】:

    【解决方案2】:

    从输入中删除禁用属性

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-23
      • 2019-11-04
      • 2016-08-25
      • 1970-01-01
      • 2016-04-29
      • 2012-08-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多