Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Dependent Dropdown help
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Astralis
Senior Member

USA
1218 Posts

Posted - 17 August 2003 :  20:13:32  Show Profile  Send Astralis a Yahoo! Message
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?


Nikkol
Forum Moderator

USA
6907 Posts

Posted - 17 August 2003 :  21:23:03  Show Profile
you are submitting the form in the onchange event of the first dropdown. don't you want to actually reload the current page specifying a category instead of submitting the form?

Nikkol ~ Help Us Help You | ReadMe | 3.4.03 fixes | security fixes ~
Go to Top of Page

Astralis
Senior Member

USA
1218 Posts

Posted - 17 August 2003 :  22:15:31  Show Profile  Send Astralis a Yahoo! Message
That is correct. I thought that's what I was doing with the following Javascript:

<SCRIPT Language="JavaScript"> 
function check(frm) 
{ 
    if ( frm.category.selectedIndex != 0 && frm.subcategory.selectedIndex != 0 ) 
    { 
        frm.action = "<%=editAction%>" 
    } 
    return true; 
} 
</SCRIPT>



Of course, it is not working and is doing exactly what you described. How would you correct it?
Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 17 August 2003 :  23:16:54  Show Profile
what does editAction equal?

Nikkol ~ Help Us Help You | ReadMe | 3.4.03 fixes | security fixes ~
Go to Top of Page

Astralis
Senior Member

USA
1218 Posts

Posted - 17 August 2003 :  23:22:07  Show Profile  Send Astralis a Yahoo! Message
Inserts data into the database. But, that javascript is supposed to check if both categories and subcategories are selected. If not, then it just reloads the page. If they are selected, it is supposed to use editaction to insert into the database. That apparently isn't happening.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.28 seconds. Powered By: Snitz Forums 2000 Version 3.4.07