我动态创建表单列表,但在提交之前,用户会获得一个jquery确认警报。我想在此确认文本中提及一个formvalue,但我无法知道如何执行此操作
<form name="team_uit_laddercompetitie_zetten_frm" method="post" class="confirm_submit">
<input type="hidden" name="todo" value="team_uit_laddercompetitie_zetten" />
<input type="hidden" name="teamID" value="<?php echo $aKlasse[$k]['teamnr'];?>" />
<input type="hidden" name="teamnaam" value="<?php echo teamnaam($aKlasse[$k]['teamnr']);?>" />
<input type="submit" id="team_uit_laddercompetitie_zetten_submit" value="TEST: uit competitie zetten" />
</form>
这是我的jquery部分:
<script type="text/javascript">
$(".confirm_submit").click( function(){
var test = $this.form.teamnaam.value;
jConfirm('xWeet u zeker dat u het team: uit de laddercompetietie wilt verwijderen?' + test, function(r) {
if(r == true)
{
//$('#team_uit_laddercompetitie_zetten_frm').submit();
alert('test');
return true;
}
else
return false;
});
return false;
});
</script>
答案 0 :(得分:6)
这将为您提供当前表单中名称为teamnaam
的元素的值
var test = $(this).closest("form").find("input[name='teamnaam']").val();