我在点击单选按钮时调用java脚本函数,并根据单选按钮我需要调用另一个java脚本函数来清除一些字段值。
问题:始终输入批准功能和字段未清除
这里是代码的快照,请仔细阅读并指导我在哪里错了,可以做些什么。
<h:selectOneRadio id="selectApprovaRl1" onfocus="return setemptyrejquery(this.form)" value="#{bean.approvalCode}"> <f:selectItem id="selDecR1" itemLabel="Approve" itemValue="Approved" /> <f:selectItem id="selDecR2" itemLabel="Reject" itemValue="Rejected" /> <f:selectItem id="selDecR3" itemLabel="Query" itemValue="Queried" /> <f:selectItem id="selDecR4" itemLabel="Pending" itemValue="Pending" /> <a4j:support event="onclick" reRender="listPanel11,listPanel22,listPanel33,listPanel44,listPanel445" /> </h:selectOneRadio>
java脚本函数
<script type="text/javascript">
function setemptyrejquery(f){
alert("running................."+f.name);
var ex1 = document.getElementById('selDecR1');
var ex2 = document.getElementById('selDecR2');
var ex3 = document.getElementById('selDecR3');
var ex4 = document.getElementById('selDecR4');
ex1.onclick = approve(f.name);
ex2.onclick = rejquery(f.name);
ex3.onclick = rejquery(f.name);
ex4.onclick = pending(f.name);
}
function approve(f) {
alert("running.......approve.........."+f);
var txt4=document.getElementById('textDec12').value="";
var txt5=document.getElementById('textDec2').value="";
alert("Reseted........approve");
}
function rejquery(f) {
alert("running.......rejquery.........."+f);
var txt4=document.getElementById('textDec1').value="";
var txt5=document.getElementById('textDec22').value="";
alert("Reseted.........rejquery");
}
function pending(f) {
alert("running.......pending.........."+f);
var txt4=document.getElementById('textDec145').value="";
var txt5=document.getElementById('textDec2245').value="";
alert("Reseted............pending");
}
</script>
html生成
<table class="form-container" width="100%">
<tbody>
<tr>
<td class="col_label">
<span id="Form:decision">
Decision
<span class="mandatory">
*
</span>
:
</span>
</td>
<td class="col_value_two">
<table id="Form:selectApprovaRl1">
<tr>
<td>
<input type="radio" name="Form:selectApprovaRl1" id="Form:selectApprovaRl1:0" value="Approved" onclick="A4J.AJAX.Submit('Form:j_id724','Form',event,{'similarityGroupingId':'Form:j_id730','parameters':{'Form:j_id730':'Form:j_id730'} ,'actionUrl':'/file.jsf'} )" onfocus="return setemptyrejquery(this.form)" />
<label for="Form:selectApprovaRl1:0"> Approve</label>
</td>
<td>
<input type="radio" name="Form:selectApprovaRl1" id="Form:selectApprovaRl1:1" value="Rejected" onclick="A4J.AJAX.Submit('Form:j_id724','Form',event,{'similarityGroupingId':'Form:j_id730','parameters':{'Form:j_id730':'Form:j_id730'} ,'actionUrl':'/file.jsf'} )" onfocus="return setemptyrejquery(this.form)" />
<label for="Form:selectApprovaRl1:1">
Reject
</label>
</td>
<td>
<input type="radio" name="Form:selectApprovaRl1" id="Form:selectApprovaRl1:2" value="Queried" onclick="A4J.AJAX.Submit('Form:j_id724','Form',event,{'similarityGroupingId':'Form:j_id730','parameters':{'Form:j_id730':'Form:j_id730'} ,'actionUrl':'/file.jsf'} )" onfocus="return setemptyrejquery(this.form)" />
<label for="Form:selectApprovaRl1:2">
Query
</label>
</td>
<td>
<input type="radio" checked="checked" name="createExportImportLicenseForm:selectApprovaRl1" id="Form:selectApprovaRl1:3"value="Pending" onclick="A4J.AJAX.Submit('Form:j_id724','Form',event,{'similarityGroupingId':'Form:j_id730','parameters':{'Form:j_id730':'Form:j_id730'} ,'actionUrl':'/file.jsf'} )" onfocus="return setemptyrejquery(this.form)" />
<label for="Form:selectApprovaRl1:3">
Pending
</label>
</td>
</tr>
</table>