I am using the below function of javascript to enable and disable the radio buttons and textbox as the value of drop down changes.
it is fine in starting but as I click on the submit button and if myindex = 8 or 9 at the time of submit it does not work.
At this time radio button filter[0] and filter[1] should be disable and textfield count should be enable I called this function in while selecting dropdown and while clicking on submit button.
I dont know why it is not working. Any Help.
function OnChange(dropdown) {
var myindex = dropdown.selectedIndex;
document.form.filter[0].disabled = false;
document.form.filter[1].disabled = false;
if (myindex == 8) {
document.form.filter[0].disabled = true;
document.form.filter[1].disabled = true;
document.form.count.disabled = false;
document.form.submit.disabled = false;
} else if (myindex == 9) {
alert("in ALL");
document.form.filter[0].disabled = true;
document.form.filter[1].disabled = true;
document.form.count.disabled = true;
document.form.submit.disabled = false;
alert(document.form.filter[0].disabled);
}
else {
document.form.filter[0].disabled = false;
document.form.filter[1].disabled = false;
document.form.count.disabled = true;
document.form.submit.disabled = false;
}
}
Here is my HTML code below.
<s:form action="crInquiry" name="form" >
<table align="center" width="1020">
<tr>
<td>Batch Id : <s:property value="batchId" />
<fieldset
style="background-color: #F7F9F3; margin: 2px; padding: 8px; -moz-border-radius: 5pt; border: 1px solid #A7CBE3;">
<legend class="field_label">
<strong>Inquiry Log Status</strong>
</legend>
<table border="0" id="main_table1" cellpadding="5" width="1010"
cellspacing="5" align="center">
<tr style="height: 5px;">
<td width="300" height="2" align="left" colspan="0"><s:hidden
name="batchId" id="batchId"
onfocus="OnChange((this.form.filterValue));"
value="%{ batchId }"></s:hidden> <s:select
cssClass="bulkSelect" name="filterValue"
label="Search Criteria" required="true" theme="css_xhtml"
labelposition="bottom" tabindex="2" list="headerList"
onchange="OnChange(this.form.filterValue);" />
</td>
<td width="180"><s:radio name="filter"
requiredposition="right"
list="#{'STATUS_FILTER_START':'START','STATUS_FILTER_END':'END'}"
label="Stage" labelposition="right" theme="css_xhtml"
tabindex="9" labelposition="bottom"></s:radio>
</td>
<td width="50" height="2"><s:textfield disabled="true"
value="0" name="count" size="2" labelposition="1"
theme="css_xhtml"></s:textfield>
</td>
<td width="180"><s:radio name="order"
requiredposition="right" list="#{'ASC':'ASC','DESC':'DESC'}"
label="Order" labelposition="right" theme="css_xhtml"
tabindex="9" labelposition="bottom"></s:radio>
</td>
</td>
<td width="50"><s:submit theme="css_xhtml" value="Filter"
align="left" onclick="gotopage('FilteredInquiryLog');"></s:submit>
</td>
<td width="59"><s:submit theme="css_xhtml" value="Details"
onclick="gotopage('crInquiry')"></s:submit></td>
</tr>
</table>
</fieldset>
</td>
</tr>
</table>
</s:form>
and from submit I call the js function from where it call the above js function
function gotopage(actionname) {
document.form.action = actionname + ".action";
document.form.submit();
OnChange(document.form.filterValue);
}
It seems odd that you would submit the form and then try to manipulate the fields…
perhaps what you need is :