Discussion Locked

Dynamic Folder Menu in ASP

0 helpful
9 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hello

I'm creating a ASP with a drop down menu. I will need the menu to be dynamic. Two drop down
menus.

One menu allows the User to choose his folder and the next menu will automatcally change its own content list inside pertaining to the first folder chosen.

Choose the files from the second menu and click, the ASP will call for the file choosen. Do you have any idea how this can be done?

Will browser upload the dynamic page? Please advise. If need be, I'll send you a picture to illustrate what I mean.

Thank you.

9 replies

by greg griffiths

Your two options are server and client side.

If you have a small amount of data then you can use Javascript on the client side, which allows you to have an ONCHANGE event on the first dropdown, which could check the value and then populate the second dropdown accordingly.

If you wish to use a server side approach or have a lot of data, then you will need to post back to the server each time and then take the value of the first dropdown as a parameter to a query to retrieve all the valuesfor it.

If you need more assistance / sample code let me know.

by todd parker

If I'm correct, you want to update the values of one Combo Box based on the values of the another combo box...

If true - then read on:

<%

ChangeBox = Request.Form("ChangeBox")

if ChangeBox = "True" then
FirstComboValue = Request.Form("ComboField1")

'--Get another recordset based on FirstCombo value, etc..
end if

%>

Combo Value 1
Combo Value 2

<%
if FirstComboField = "Value1" then
%>
Combo Value 3
<%
else
%>
Combo Value 4
%>

Thehidden field is just a means to determine if the form was submitted because they made a change in the combo box, or if it was just simply submitted naturally through a submit button. It's up to you if you want to use it.

I think this should get your wheels turning. If questions, just ask.

Regards,
-Parker

by todd parker

I didn't add the commands in there. FIgured you would have already guessed it, but just in case.... put it in there. Oh, and I incorrectly spelled the function name "KindaSubmitTheForm" in the On-Change event of the . FYI.

-Parker

by madestroitsolutions

Well, the 2nd answer is somewhat correct, but its not really explaining you what is happening.
The way this is going to work is as follows:

1) When the page loads for the first time, you will populate "COMBO A" with the folder names. You check for a value for "COMBO A". If no value was passed to this page, you know its the first time its being loaded, so you want to populate "COMBO B" with the file names for the first entry in "COMBO A".

2) When user selects a folder in "COMBO A", you will programmatically SUBMIT the form to itself, using Javascript in the ONCHANGE event (preferably).

3) The page loads for a second time. You check for a value for "COMBO A". You get the value that was submitted in previous step, so you know the form is being loaded for a second time. Based on this value, you will populate "COMBO A" again, mark the appropiate option as "SELECTED", retrieve a list of files from the folder selected by the user and populate "COMBO B" with it.

4) User selects something in "COMBO B", and submits this information.
-------------------------------------------

Keep in mind that ASP runs server side, which is why you have to submit the page to itself, so it can load the file names in the second time it is called, based on the value of "COMBO A"

This is just one of the ways in which this can be done. To my judgement, this is the most effective, fast, and memory efficient way.

I can send you an illustration of the actual code implementation if you write me at: juanja01@optonline.net

Good Luck!

This discussion is closed to new replies.