使用jquery在同一个php页面中将输入值从一种形式传递到另一种形式,以提交第二种形式时丢失的所有值结束

时间:2016-09-28 14:37:28

标签: jquery html

我试图通过jquery在同一个php页面中将值从一个表单传递到另一个表单。 数据正确传递,但是当我使用方法发布提交第二个表单时,我丢失了所有值。 提前谢谢。

<form id="form1">
   <input name="producto" type="text">
   <button id="cd-cart-trigger" type="button">GO</button>
</form>

<script>
    $(function(){
      var form1 = $('#form1'), 
          form2 = $('#form2');  

      $('#cd-cart-trigger').click(function(){
        $(':input[name]', form2).val(function(){
          return $(':input[name='+ this.name +']', form1).val();
        });
      });
    });
</script>

<form id="form2" action="sender.php" method="post">
   <input name="producto" type="text"/>
   <input class="side_form_button" type="submit" value="GO" />
</form>   

0 个答案:

没有答案