使用jquery选中复选框时获取文本框值 [英] Get the textbox value when checkbox checked using jquery

查看:312
本文介绍了使用jquery选中复选框时获取文本框值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在选中复选框时获取该功能中的texbox值



我尝试过:



< table>

<?php foreach($ list_points as $ points):

$ i = 1; ?>



< tr class =gradeA>

< td><?php echo $ points ['vehiclename'] ?>< / td>

< td>< input type =textname =ptimeid =ptime-text<?php echo $ i;?> class =ptime-text>< / td>

< td>

< div class =i-checks ptime-check& gt;

< label>

< input type = checkboxvalue =target =ptime-text<?php echo $ i;?> class =testonclick =check_ptime();> < I>< / I>

< / label>

< / div>

< / td>

< / tr>

<?php $ i ++; endforeach; ?>



< / table>







我的剧本功能是





function check_ptime()

{

alert($(this).parent()。parent()。parent()。 parent()。find('。ptime-text')。val()); //这里我需要thextbox的值

}

i need to get the texbox value in the function when checking the checkbox

What I have tried:

<table>
<?php foreach ($list_points as $points):
$i=1; ?>

<tr class="gradeA">
<td><?php echo $points['vehiclename'] ?></td>
<td><input type="text" name="ptime" id="ptime-text<?php echo $i; ?>" class="ptime-text"></td>
<td>
<div class="i-checks ptime-check"&gt;
<label>
<input type="checkbox" value="" target="ptime-text<?php echo $i; ?>" class="test" onclick="check_ptime();"> <i></i>
</label>
</div>
</td>
</tr>
<?php $i++;endforeach; ?>

</table>



my script function is


function check_ptime()
{
alert($(this).parent().parent().parent().parent().find('.ptime-text').val());//here i need the value of thextbox
}

推荐答案

list_points as
list_points as


points):
points):


i = 1; ?>



< tr class =gradeA>

< td><?php echo
i=1; ?>

<tr class="gradeA">
<td><?php echo


这篇关于使用jquery选中复选框时获取文本框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆