我有以下功能的 js 文件(rework.js)
/**
* Java script functions to set comments for selected rework reason.
*/
function setReworkCheckFields() {
var note = $("#rework_note").val();
var reworknoteImage = document.getElementsByName("reworknote_image");
var reworknoteScript = document.getElementsByName("reworknote_script");
var reworknoteVoice = document.getElementsByName("reworknote_voice");
var reworknoteMusic = document.getElementsByName("reworknote_music");
if ($(reworknoteImage).is(':checked')) {
$("#reworknote_image_note").val(note);
}
if ($(reworknoteScript).is(':checked')) {
$("#reworknote_script_note").val(note);
}
if ($(reworknoteVoice).is(':checked')) {
$("#reworknote_voice_note").val(note);
}
if ($(reworknoteMusic).is(':checked')) {
$("#reworknote_music_note").val(note);
}
}
我已经在 html 中导入了这个 js 文件,并且我在 html 中添加了具有不同实现的相同方法,如下所示
<script type='text/javascript' src='style/js/rework.js'></script>
<script type='text/javascript'>
function setReworkCheckFields() {
var note = $("#rework_note").val();
var reworknoteImage = document.getElementsByName("reworknote_image");
var reworknoteScript = document.getElementsByName("reworknote_script");
var reworknoteVoice = document.getElementsByName("reworknote_voice");
var reworknoteMusic = document.getElementsByName("reworknote_music");
if ($(reworknoteImage).is(':checked')) {
$("#reworknote_image_note").val(note);
} else {
$("#reworknote_image_note").val(null);
}
if ($(reworknoteScript).is(':checked')) {
$("#reworknote_script_note").val(note);
} else {
$("#reworknote_script_note").val(null);
}
if ($(reworknoteVoice).is(':checked')) {
$("#reworknote_voice_note").val(note);
} else {
$("#reworknote_voice_note").val(null);
}
if ($(reworknoteMusic).is(':checked')) {
$("#reworknote_music_note").val(note);
} else {
$("#reworknote_music_note").val(null);
}
}
</script>
并调用下面的javascript函数。
<table>
<tr>
<td>Image: <input type="checkbox" name="reworknote_image" ${reworknote_image.workingchecked} onchange="setReworkCheckFields()"/></td>
<td>Script: <input type="checkbox" name="reworknote_script" ${reworknote_script.workingchecked} onchange="setReworkCheckFields()"/></td>
<td>Voice: <input type="checkbox" name="reworknote_voice" ${reworknote_voice.workingchecked} onchange="setReworkCheckFields()"/></td>
<td>Music: <input type="checkbox" name="reworknote_music" ${reworknote_music.workingchecked} onchange="setReworkCheckFields()"/></td>
</tr>
</table>
有人可以知道流程将如何运作。这有效吗?