Ok, first off I am not a fan of using Javascript. I do most of my coding in JSP so when I work with Javascript along with that I get a headache. So I am basically a beginner with it. My problem is have a select that has to options(Insert, Update). If insert is selected, it should set the form's action to 'AddRates.jsp' and disable a checkbox. If update, then it should set it to 'UpdateRates.jsp' and disable a text box. Any help would be very much appreciated, I have tried a few different ways to do this with no luck.
Here is my code....
<% String report = ""; %>
<script language="JavaScript" type="Text/JavaScript">
function SelectValue( SelectControl )
{
return SelectControl.options[ SelectControl.selectedIndex ].value;
}
function Init()
{
ChangeReport(SelectValue( document.forms[ 0 ].ReportType ));
}
function ChangeReport(ReportType)
{
switch (ReportType)
{
case 'Insert':
document.EditRatesForm.newJONs.disabled = "true";
alert("Insert"
;
<% report = "AddRates.jsp"; %>
break;
case 'Update':
document.EditRatesForm.newJONs.disabled = "false";
alert("Update"
;
<% report = "updateRates.jsp"; %>
break;
Default:
alert("Help"
;
break;
}
}
</script>
<form action="<%= report %>" method="Post" name="EditRatesForm">
<select name="ReportType" id="ReportType" onChange="ChangeReport( SelectValue( this ) );">
<Option>Insert</Option>
<Option>Update</Option></select>
<input type="checkbox" name="newJONs" value="OFF">
<input type="text" name="numJONs" size="3">
<input type="submit" value="Submit" name="submit">
I left some snippets of the code out just cause it was more design parts of the code.
Here is my code....
<% String report = ""; %>
<script language="JavaScript" type="Text/JavaScript">
function SelectValue( SelectControl )
{
return SelectControl.options[ SelectControl.selectedIndex ].value;
}
function Init()
{
ChangeReport(SelectValue( document.forms[ 0 ].ReportType ));
}
function ChangeReport(ReportType)
{
switch (ReportType)
{
case 'Insert':
document.EditRatesForm.newJONs.disabled = "true";
alert("Insert"
<% report = "AddRates.jsp"; %>
break;
case 'Update':
document.EditRatesForm.newJONs.disabled = "false";
alert("Update"
<% report = "updateRates.jsp"; %>
break;
Default:
alert("Help"
break;
}
}
</script>
<form action="<%= report %>" method="Post" name="EditRatesForm">
<select name="ReportType" id="ReportType" onChange="ChangeReport( SelectValue( this ) );">
<Option>Insert</Option>
<Option>Update</Option></select>
<input type="checkbox" name="newJONs" value="OFF">
<input type="text" name="numJONs" size="3">
<input type="submit" value="Submit" name="submit">
I left some snippets of the code out just cause it was more design parts of the code.