Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/380.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 从行内的div中查找最接近的值_Javascript_Jquery_Forms_Jquery Selectors - Fatal编程技术网

Javascript 从行内的div中查找最接近的值

Javascript 从行内的div中查找最接近的值,javascript,jquery,forms,jquery-selectors,Javascript,Jquery,Forms,Jquery Selectors,我正在尝试从单击的行表单中的表单中查找值。我正在使用这个脚本。我可以从表单字段中获取值。但它给了我相同的值,并且它只给了我第一行的值,如果单击任何一行 我想在点击td链接后打开表格,该链接位于类别名为“.followupform”的行内 打开“.followupform”链接(表格)后。我想通过单击当前行的“.updatefollowupstatus”从字段中获取值 $(".updatefollowupstatus").click(function(e){ var row = $(this

我正在尝试从单击的行表单中的表单中查找值。我正在使用这个脚本。我可以从表单字段中获取值。但它给了我相同的值,并且它只给了我第一行的值,如果单击任何一行

我想在点击td链接后打开表格,该链接位于类别名为“.followupform”的行内 打开“.followupform”链接(表格)后。我想通过单击当前行的“.updatefollowupstatus”从字段中获取值

$(".updatefollowupstatus").click(function(e){ 
  var row = $(this).closest('td>.popover-content>form')
  var status= $(row).find(".fformstatus").val();
  var comment= $(row).find(".fformcomment").val();
  var ffid= $(row).find(".fformffid").val();
  alert(ffid);
});


    <td style="text-align:center">
                  <a href="#" class="followupform"><i class="fa fa-edit"></i></a>                           <div class="hide img-rounded popover-content">
                     <strong style="text-align:center">Update Followup Status</strong><span class="pull-right ffclose" style="cursor: pointer;"><i class="fa fa-close"></i></span>
                     <hr>
                      <form class="form-inline" role="form">
                        <div class="form-group">
                          <select class="form-control fformstatus" name="fformstatus">
                            <option value="0">Followups Status</option>
                            <option value="VM">VM</option>
                            <option value="Callback">Callback</option>
                            <option value="Rude">Rude</option>
                            <option value="Done">Done</option>
                          </select>         
                        </div>  
                        <div class="form-group">  
                          <textarea placeholder="Follow up Comment overview" class="form-control fformcomment"></textarea>
                          <input type="text" class="fformffid" hidden="" name="fformffid" value="15">
                        </div>        
                        <div class="form-group">  
                          <div class="btn btn-primary updatefollowupstatus">Update »</div>                                  
                        </div>
                      </form>
</div><!-- Form Content -->
                  </td>
$(“.updatefollowupstatus”)。单击(函数(e){
var row=$(this).closest('td>.popover content>form')
var status=$(行).find(“.fformstatus”).val();
var comment=$(行).find(“.fformcomment”).val();
var ffid=$(行).find(“.fformffid”).val();
警报(ffid);
});
更新后续状态

后续状态 虚拟机 回拨 粗鲁的 多恩 更新»

我用了所有可能的方法。但我认为这是一个错误或其他方法。我的目标是更新当前行的反馈,并通过ajax发送值进行处理。

最好使用
.parents()
方法,因为表单是所单击按钮的父元素

试试下面的代码

$(".updatefollowupstatus").click(function(e){ 
   var frm = $(this).parents('form');
   var status= $(frm).find(".fformstatus").val();
   var comment= $(frm).find(".fformcomment").val();
   var ffid= $(frm).find(".fformffid").val();
   alert(ffid);
});

最好使用
.parents()
方法,因为表单是所单击按钮的父元素

试试下面的代码

$(".updatefollowupstatus").click(function(e){ 
   var frm = $(this).parents('form');
   var status= $(frm).find(".fformstatus").val();
   var comment= $(frm).find(".fformcomment").val();
   var ffid= $(frm).find(".fformffid").val();
   alert(ffid);
});

您在[closest()][1]中的
.closest('td>.popover content>form')
中使用了错误的选择器,只需使用
.closest('form')

$(“.updatefollowupstatus”)。单击(函数(e){
var行=$(this).closest('form');
var status=$(行).find(“.fformstatus”).val();
var comment=$(行).find(“.fformcomment”).val();
var ffid=$(行).find(“.fformffid”).val();
警报(状态+”、“+注释+”、“+ffid);
});

更新后续状态

后续状态 虚拟机 回拨 粗鲁的 多恩 更新» 更新后续状态
后续状态 虚拟机 回拨 粗鲁的 多恩 更新»
您在[closest()][1]中的
.closest('td>.popover content>form')
中使用了错误的选择器,只需使用
.closest('form')

$(“.updatefollowupstatus”)。单击(函数(e){
var行=$(this).closest('form');
var status=$(行).find(“.fformstatus”).val();
var comment=$(行).find(“.fformcomment”).val();
var ffid=$(行).find(“.fformffid”).val();
警报(状态+”、“+注释+”、“+ffid);
});

更新后续状态

后续状态 虚拟机 回拨 粗鲁的 多恩 更新» 更新后续状态
后续状态 虚拟机 回拨 粗鲁的 多恩 更新»
行没有
-它不是表单字段。没有行形式这样的东西。一行有单元格(
td
元素),这些单元格有
textContent
和/或
innerHTML
(或在JQuery中:
text()
和/或
html()
)。您可以选择父窗体而不是行$(.updatefollowupstatus”)。单击(函数(e){var form=$(this)。父('form')var status=$(form)。查找(“.fformstatus”).val();var comment=$(form)。查找(.fformcomment”).val();var ffid=$(form)。查找(.fformffid”).val();警报(ffid);};行没有
-它不是表单字段。没有行形式这样的东西。一行有单元格(
td
元素),这些单元格有
textContent
和/或
innerHTML
(或在JQuery中:
text()
和/或
html()
)。您可以选择父窗体而不是行$(.updatefollowupstatus”)。单击(函数(e){var form=$(this)。父('form')var status=$(form)。查找(“.fformstatus”).val();var comment=$(form)。查找(.fformcomment”).val();var ffid=$(form)。查找(.fformffid”).val();警报(ffid);};谢谢Prashant,你的建议奏效了。我必须为每个表单分配动态类名,以便从表单中获取动态值。现在工作很好。欢迎萨哈尔!很高兴它帮助了你谢谢Prashant,你的建议奏效了。我必须为每个表单分配动态类名,以便获得动态值