I have a category menu and a subcategory menu. The subcategory menu changes based on what is selected in the category menu. When one selects a category, it reloads the page, and shows the subcategories - well, that's what it's supposed to do. Instead, mine isn't reloading the page. Instead it's inserting everything in the database as if I completed the form.
This is the JS which checks if the fields are selected. If they are both selected it it should send it to the edit script which inserts it into the database. If not, it should just reload the form:
<SCRIPT Language="JavaScript">
function check(frm)
{
if ( frm.category.selectedIndex != 0 && frm.subcategory.selectedIndex != 0 )
{
frm.action = "<%=editAction%>"
}
return true;
}
</SCRIPT>
This is the form name:
<FORM name=fHtmlEditor METHOD="POST" onSubmit="return check(this);">
This is the Category Select menu:
<SELECT Name="CategorySelect" MULTIPLE size=10
onChange="document.fHtmlEditor.submit();">
<OPTION Value="NONE">-- choose a category below--
<% For cnum = 0 To UBound(catRows,2) %>
<OPTION Value="<%= catRows(0,cnum) %>"
<% If catRows(0,cnum) = catChosen Then %>
SELECTED
<% End If %>
><%= catRows(1,cnum) %>
<% Next %>
</SELECT>
This is the Subcategory Select Menu
<SELECT Name="SubcategorySelect" MULTIPLE Size=10
onChange="goNextPage(this);" >
<% If showSubcat = False Then %>
<OPTION Value="0">-- no subcategories yet --
<% Else %>
<OPTION Value="0">-- choose a subcategory below--
<% For cnum = 0 To UBound(subRows,2) %>
<OPTION Value="<%= subRows(0,cnum) %>"><%= subRows(1,cnum) %>
<% Next %>
<% End If %>
</SELECT>
What am I doing wrong?