我有以下javascript代码正常工作,但var form = this.form.id是否正确?
$("#Wnoreportyet").click( function() {
var form = this.form.id
$("#dialog-noreportyet").dialog({
buttons : {
"Ακύρωση" : function() {
document.getElementById(form).Wnoreportyet.checked = 0;
$(this).dialog("close");
},
"ΟΚ" : function() {
document.getElementById(form).submit();
$(this).dialog("close");
}
}
});
});
我不确定这是因为在jsp(html)代码中我使用了多个表单。
<div id="subtabs-6">
<div id="draggable6" class="ui-state-highlight">
<h3 class="ui-widget-header">Έκθεση ελέγχου</h3>
<table width="100%" cellspacing="0">
<tr>
<form id="fileupload" method="post" enctype="multipart/form-data" action="upload.jsp"><input type="file" name="ImageFile" id="ImageFile" />
<td width="14%" align="left">Βήμα 1
</td>
<td colspan="2" align="left">
<button type="submit" name="button" id="button3" onclick="return thissubmit('fileupload');">Ανέβασμα</button>
<input name="Wupdatekind" type="hidden" value="auditreport" /></td>
</form>
</tr>
<form id="formauditreport" method="post" action="appointofcaid_update_finish.jsp">
<tr>
<td rowspan="3" align="left">Βήμα 2 </td>
<td colspan="2" align="left"><input type="checkbox" name="Wnoreport" id="Wnoreport" /> Ολοκληρώθηκε χωρίς έκθεση</td>
</tr>
<tr>
<td width="25%" align="left">Ημ καταχώρισης</td>
<td width="61%" align="left">01/10/2015</td>
</tr>
<tr>
<td align="left">Ημ έκθεσης</td>
<td align="left"><input name="Wreportdate" type="text" id="Wreportdate" value=""></td>
</tr>
<tr>
<td colspan="3" align="center">Δεν ολοκληρώθηκε ο έλεγχος
<input type="checkbox" name="Wnoreportyet" id="Wnoreportyet"
disabled="disabled"/>
</td>
</tr>
<tr>
<td colspan="3" align="center"><button type="submit" name="sbutton6" id="sbutton6" value="Ενημέρωση">Ενημέρωση</button>
<input name="Wupdatekind" type="hidden" value="auditreport" /></td>
</tr>
</form>
</table>
</div>
答案 0 :(得分:1)
假设该复选框位于您需要获取id的表单内:
// Make the form a modal dialog and create a button
$('#emailModal').dialog({
modal: true,
autoOpen: false,
title: "Enter your information",
buttons: {
"Send": function() {
if ($('#emailPost2').submit())
{
$(".appendEmail").append("<tr><td>" + $(".email").val() + "</td></tr>");
$(this).dialog("close");
}
}
}
});
更多信息: