在打开模态之前将表单数据保存到会话

时间:2017-01-18 06:14:54

标签: javascript php jquery ajax

我是jquery和javascript的新手。 我有一个表格X,它有2个按钮,1表示提交表格X,1表示开放模态(包含表格Y)。但是当我提交表单Y时,表单X中的数据将丢失。 是否有可能当我点击按钮打开模式时,我将数据表格X保存到jquery帖子的会话?我应该怎么做?

<form action="" method="post" id="fx">
  <input type="text" name="fx1">
  <input type="text" name="fx2">
  <input type="button" name="open" data-toggle="modal" data-target="#modal">
  <input type="submit" name="submit" value="submit">
</form>

<div class="modal fade bd-example-modal-lg" id="modal" tabindex="-1" role="dialog" aria-labelledby="modalSatuanKerjaLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <form class="form-horizontal" method="POST" action="" id="fy">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
        <h4 class="modal-title" id="myModalLabel">Tambah Satuan Baru</h4>
      </div>
      <div class="modal-body">        
        <div class="form-group">
          <label class="col-md-2 control-label">Satuan</label>
          <div class="col-md-10">
            <input type="text" class="form-control" name="tsatuan[]" placeholder="Satuan" id="sat" required autofocus></input>                         
            <input type='hidden' name='page' value='pekerjaan'>
            <input type='hidden' name='mpage' value='satuan'>
          </div>
        </div>        
      </div>
      <div class="modal-footer">
        <button type="submit" id="btnSatuan" class="btn btn-primary" name="tambah" value="T">Simpan</button>
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Keluar</button>        
      </div>
      </form>
    </div>
  </div>
</div>

0 个答案:

没有答案