javascript - 如何使用 jQuery 获取值?

标签 javascript jquery

我有两个表单和一个验证按钮,我希望 form1 显示,form2 隐藏,当我单击验证按钮时,我希望 form1 隐藏,form2 显示,对于我现在想要显示的日期。 form1 的值也按其位置显示在 form2 中。

form1 的值也按其位置显示在 form2 中。

表格1

  <script src="https://code.jquery.com/jquery-3.3.1.js"></script>

  <!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

  <!-------------------------------->
  <div id="form1">
          <label for="titre">DAY pointage</label>
          <input type="date" name="datep" class="form-control">
          <br>
              <label for="titre">Chantier</label>
              <select class="form-control" id="chantier_id">
                <option selected disabled>Select Location</option>
                <option value="1">azilal</option>
                <option value="2">asfalou</option>
                <option value="3">ihjamn</option>
              </select>
          <br>
             <label for="titre">Ouvrage</label>
              <select class="form-control" id="ouvrage_id">
                        <option value="0" selected disabled>- Select -</option>
                        <option value="1">assinissement</option>
                        <option value="2">installation</option>
              </select>
          <br>
             <label for="titre">default nbre day</label>
             <input type="text" name="nbre" class="form-control" value="1">
          <br>
            <button class="btn btn-theme " type="submit" >valider</button>
          <br>
          <br>

</div> 

表格2

<div id="form2">

              <br>
              <div>Day : dayPointage , Chantier : chantierSelected , Ouvrage : ouvrageSelected</div>
              <table id="example" class="table table-striped table-bordered" style="width:100%">
                 <thead>
                  <tr>
                    <th><input type="checkbox" id="check_all"></th>
                    <th>nom prenom</th>
                    <th>cin</th>
                    <th>matricule</th>
                    <th>default nbre day</th>
                  </tr>
                 </thead>
                <tbody>
                  <tr id="1">
                    <td><input type="checkbox" class="checkbox" name="customer_id[]" value="1" /></td>
                    <td>MARZOUK NAJIB</td>
                    <td>Pa130191</td>
                    <td>2925019599</td>
                    <td value="1"><input type="text" name="nbre" class="form-control" value="default nbre day"></td>
                  </tr>
                   <tr id="2">
                    <td><input type="checkbox" class="checkbox" name="customer_id[]" value="2" /></td>
                    <td>achraf bourki</td>
                    <td>pa5000</td>
                    <td>202020</td>
                    <td value="2"><input type="text" name="nbre" class="form-control" value="default nbre day"></td>
                  </tr>
                </tbody>
              </table>
</div>

jQuery $(文档).ready(函数() {

    $('#check_all').on('click', function(e) {
     if($(this).is(':checked',true))  
     {
        $(".checkbox").prop('checked', true);  
     } else {  
        $(".checkbox").prop('checked',false);  
     }  
    });
     $('.checkbox').on('click',function(){
        if($('.checkbox:checked').length == $('.checkbox').length){
            $('#check_all').prop('checked',true);
        }else{
            $('#check_all').prop('checked',false);
        }
     });
     });

最佳答案

$('#form2 [name=nbre]').val($('#form1 [name=nbre]').val())

每个输入都相同

关于javascript - 如何使用 jQuery 获取值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60249993/

相关文章:

javascript - 自动完成远程源多个输入

jquery - 使用javascript和onclick显示一个div

javascript - jQuery 表单验证 - 一次报告所有错误

javascript - jquery链接标签href与onclick需要两次点击才能加载ajax

javascript - Selenium 表格提交

javascript - 根据窗口大小动态调整图像缩略图,全出血

javascript - 如何打破输入字段值的行

javascript - Three.JS - Firefox 中的滚动问题

jQuery - 更改 CSS3 按钮文本?

javascript - 使用 jQuery 在旋转木马中调整 div 的大小