提交时未返回 jQuery 输入值

标签 jquery html forms input

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

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>

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

如果我输入我的输入(如正常形式),则会返回我的值。

有什么想法吗?

最佳答案

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

关于提交时未返回 jQuery 输入值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46524209/

相关文章:

jquery - 位置为 : fixed inside a jQuery UI Dialog Box doesn't float to the bottom 的 Div

javascript - Jquery draggable and droppable,切换到originalPosition另一个draggable

html - 图标在 IE7 中不显示

html - 悬停时如何更改很多img

javascript - 如何为表单提交事件创建回调(没有ajax)

javascript - 通过单击父行激活复选框

jquery - 如何将 JQuery-ui 选项卡设计更改为看起来像 Microsoft AJAX 工具包 TabContainer

javascript - Fullcalendar - 允许一些事件可拖动,一些事件不可拖动

javascript - SVG 平移和缩放不起作用

php - Symfony2 ManytoMany 双向关系 - 如何手动持久化