Link to home
Start Free TrialLog in
Avatar of DanielR6
DanielR6Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Trouble With Three Dependent Drop Down Boxes - Using ASP, Javascript, AJAX

Hi,
I know this question has been answered in various ways, though there never quite what im looking for. Im happy to receive help/solutions in any combination of asp/ajax/javascript. Some advice on which option would be best, i've seen javascript examples where all the data is collected and all the options are done in one hit, or asp where after each selection is made a call back to the server to update the next box is done. My database will pull out up to 500 records maximum.

So this is what I'm trying to achieve;
( Currently all this is in the one table, I have seen examples that use seperate tables and join them, but due to limited knowledge i've been unable to modify them)

From the Access table there are three select boxes that I need to populate;

1st Select Box = Manufacturers
Gather all manufactuers, only need one of each name, so I did try SELECT DISTINCT

2nd Select Box = Models
Gather all models in relation to the selection made in Select Box(Manufacturers). Again only show one of each model

3rd Select Box = Deriative
Similar to the others grab all deriatives that relate to the selection made in Select Box(Models)

I have found something here on EE which maybe what I'm looking for, but I seem to get a javascript error. i would post the code but it is in EE Members only, the link, https://filedb.experts-exchange.com/incoming/ee-stuff/4370-dbfun_ajax.zip.

Advice or good examples of this would be appreciated

Dan
Avatar of Alemus
Alemus

Try this
http://forums.aspfree.com/code-bank-54/dynamic-triple-linked-dropdowns-99849.html

I use a variation that only links two, but it works great.
Avatar of b0lsc0tt
DanielR6,

Thanks for your interest in my work. :)  The ee-stuff file is one I uploaded.  I see you already have an  expert response and am not sure if you need more but that file was for the closed question at http:/Q_22770695.html .  If the comment above doesn't provide all you need or you have a question about doing this then let me know.  Enjoy this project, it sounds fun. :)

b0lsc0tt
Avatar of DanielR6

ASKER

Thanks Alemus for that link. I given it a try and it seems to work fine.

Dan
b0lsc0tt

Thank you for your reply, I noticed that it was your work I had stumbled onto, Im reasonably new to EE and was looking for a way to get in contact with you for some advice, but it seems they dont have a way of internally contacting other members, or have I missed something?
The previous example from Alemus, and I certainly don't want to sound ungrateful here works fine and was running within minutes, but Im interest in progressing with your example for my project.

I am in need of a little helping hand, I seem to be struggling to alter the sql in order to get the required results from a single table rather than joining two seperate ones. I dont know whether my first posting provides enough info for you to go on so heres an update

My database holds around 400 - 500 records. The three columns that I'm interested in are stk_Manufacturers, stk_Model, stk_Deriative, as from that posting i trying to get them to relate as such. So far all I've manged is to get the first drop down populated, however if I try to do a SELECT DISTINCT it returns nothing!!

Help on this would be greatly received
Dan
b0lsc0tt

Would you mind giving me some assistance with this project, I still seem to be incorrect with the SQL.

Thanks
Dan
Dan,
I will be glad to.  Some work projects, etc have taken me away from EE so I haven't had a chance to look over your response yet.  I hope to a little later today (unless a new thing comes up).
bol
I think I will need more info.  Thanks for what you have provided though.
How are you using Select Distinct?  I am not sure why you would need it and so curious what you SQL query is like and the data in the DB for those fields.  The first pull down fills from the start, correct?  Are you able to select and item in it (Manufacturers) and then have the Models list populate?  Are they the correct results?
Did my files work for you just as they were in the zip (maybe a modification for the connection, etc)?
What is the script error you mentioned?  Please provide details on the error message, the code for that part of the page and any other info like it.
The records in that DB were few if I remember right but the fact you have 400-500 should not change the basic steps you can use.  Those pages should show that but uses a simple table and example to do it.  Adapting it for a real example will hopefully still be easy but I guess I am a little unclear exactly where the problem is.  If you can provide those details we should be able to help.  Let me know if you have a question about anything I have said.
bol
b0lsc0tt

Sorry about the delay in getting back to you, work has been hectic.

It must have been something I done, as after downloading them again they worked fine.

I've had a play around with your example and I seem to have got it working correctly. One question though, the dropdowns in this example are displayed as you select the previous option, is it possible to alter them so that all three dropdowns are displayed initially but the second and third would be greyed out and unselectable until a selection is made from the first, then second etc. I know that this purely for aesthetics but if you know a way or have seen an example, I would be great full

Thanks
Dan
>> work has been hectic <<
Same here.  I hadn't even noticed. :)  Thanks for the apology though.
>> after downloading them again they worked fine <<
Great!
>> is it possible to alter them so that all three dropdowns are displayed initially but the second and third would be greyed out and unselectable until a selection is made from the first, then second etc <<
That is definitely possible.  This usually involves a little more Javascript but it can be done and is often done that way.  I can help with specifics but your .html page (or the main page) would have the form and all the fields just as you want and described.  The second and third would not have any options in them except maybe a first, default option.  They can be disabled easily just using the tag's attribute.
The server script would now send just the info for the option to the AJAX script.  In other words instead of html for a select and options you might send just a string or JSON with the name and value for each option.  No html.  The Javascript gets that response, processes the info, uses the DOM to add the option tags, and then enables the select.
I can help with specifics if you need them.  I won't have time til later tonight to do a lot so let me know what details you will need, if any.  Some of the above I would expect you can do on your own now that you know what is needed and the steps.  If you have a question about anything I have said then let me know.
bol
ASKER CERTIFIED SOLUTION
Avatar of b0lsc0tt
b0lsc0tt
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you bol for your time in modifying the code, due to christmas duties I've only just had chance to do some work on the project and have a look over your changes. If I get any issues tho i'll let you know.

Dan
I am glad you were able to come back.  Let me know how that helps or if you have a question.
bol
Hi bol
Hope you had a good festive period

I've been spending some time working on this, but seem to be experiencing problems. I'm trying to pick things up as fast as possible but alot of this is beyond my current skills, things are a bit messy so please bear with me!

I've uploaded a zip file including a sample of my database and alterations to date.
https://filedb.experts-exchange.com/incoming/ee-stuff/7444-LinkedDropdowns.zip

(dbfunredux_ajax_stock.htm) Here's what I'm trying to achieve.
a) The manufacturers dropdown is to display all available manufacturers, but no duplicate names. With the manufacturer dropdown can it be altered so that when you make a selection it populates the model dropdown not itself.
b) The model dropdown is to display all models relating to the selected manufacturer, again no duplicate names.
b) Now I've also tried adding a third dropdown box named deriative which needs to be populated by the selection made in the model dropdown.
c) I also wanted to remove the preset 'Please select one' that is displayed and just have a blank select box before a selection is made. Where is this stored as I could'nt find it?

On your original dbfunredux_ajax.htm, the final result is written out as text, can this be replaced by the deriative dropdown and it's options.

(dbfunredux_ajax_lookup_stock.asp) Here's what I'm trying to achieve.
The 1st SQL Case 1 - needs to gather all manufacturers, but no duplicates.
The 2nd SQL Case 2 - joins models to manufacturers, again no duplicate names
The 3rd SQL Case 3 - joins deriatives to models, and as with the other two no duplicate names.

I hope all this has been explained well enough to get the idea out, if not just ask. I do appreciate your help with this project.

Thanks
Dan


Dan,
I'm glad I could help.  Let me know if I am off but it seems most of what you mentioned or asked is continuing on in this project from what was originally asked here.  If I am right then we really need to close this question and, if you need help with another part, open a new question for it.  We can't take care of all of the questions, answers and a whole project in one question.
Let me know your response to the above, especially if you feel the original question has not been answered.  I know there is more to do in the project but it is important to do things as they are suppose to be done for stuff on this site.  Let me know if you have a question.
bol
Bol, no your right, all my questions can't be answered at once, thanks again for your help so far, i'll post the other questions individually.

Dan
Your welcome!  I'm glad I could help.  It has been a fun question.  Thanks for the grade and the points.
If you do open new questions and would like my attention to them then feel free to post the new question's URL here in a comment.  I have less time to help on EE right now so might not be able to respond quickly but would be glad to look and try, especially if you get no other responses or the question stalls.
bol
Hi bol,

I've opened a new question with regards to one of the questions I posted above. I've displayed the coding that you supplied me as it was originally, I hope thats ok. I tried altering it to fit my database but it got completely screwed up, so I thought I go through each step bit by bit.

The new post is here:
https://www.experts-exchange.com/questions/24050625/Trouble-With-Three-Dependent-Drop-Down-Boxes-Using-ASP-Javascript-AJAX-Follow-On.html

Dan
Dan,
Thanks.  I have saved a bookmark to the page and will try to look at it later.  If I can help I will post but right now I have been pretty busy with other things.  Haven't had much time for EE and, when I do, just quick stuff.  I will definitely look at it though when I can.  Luckily there are also many other experts here too. :)
bol
bol,

I know you're busy with things other than EE, but have you had any chance to look at my question, as I've had 0 replies from any other expert and now hit a bit of a brick wall on things.

Cheers
Dan
Dan,
I will try to take a look tonight or in the next few days.  I am just swamped with work projects and contract jobs.  I have to make time for those things first when they come up.  Having a motherboard die Friday night did not help things for my free time this weekend.  I will try to spend at least a few minutes tonight and see if I can post to get things moving.
bol