473,320 Members | 1,865 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Help needed in Multiple combo box concept

10
hi

Iam working with the multiple combo boxes concept in which i need to select the first combo box and when it is active i need to select its respective specification in the second combo box.........can you please help me out.....
May 10 '07 #1
8 2011
dmjpro
2,476 2GB
that means on changing a combo box the respective lists will come up in the second combo box....

having this assumtion i m responding u......

try to do it with AJAX..


best of luck .....
kind regards.
May 10 '07 #2
pbmods
5,821 Expert 4TB
So you want to do something like this:

|SELECT 1|
  • Apple
  • Orange
  • Grapefruit

If the User selects 'Apples', then:
|SELECT 2|
  • Juice
  • Cider
  • of my eye

But if the User selects 'Orange', then:
|SELECT 2|
  • Juice
  • Strawberry Banana
  • you glad you have a sense of humor?

instead. Is this the idea?

This would be easy enough to implement; all you have to do is dynamically create the options for each select box when the onchange event fires from the previous select. In other words:

[HTML]
<select id="cat1" onchange="loadOptions('cat2', this);">
<option ...>
</select>

<select id="cat2" onchange="loadOptions('cat3', this);">
etc.
[/HTML]

Expand|Select|Wrap|Line Numbers
  1. function loadOptions(target, source) {
  2.  
  3.     var callback = function(response) {
  4.     // Load options.
  5.     var options = eval('(' + response  + ')');
  6.  
  7.     /*
  8.     Assume that ajaxLoadOptions makes an ajax call and returns a JSON-format string.  E.g., assume that options = {
  9.         one: 'juice',
  10.         two: 'cider',
  11.         three: 'of my eye'
  12.     }
  13.     */
  14.  
  15.     //  Remove options from the target.
  16.     while(target.firstChild)
  17.         target.removeChild(target.firstChild);
  18.  
  19.     //  Append new options.
  20.     for(idx in options) {
  21.         var newElement = document.createElement('option');
  22.         newElement.setAttribute('value', idx);
  23.         // You might be able to use newElement.text here.
  24.         newElement.firstChild.nodeValue = options[idx];
  25.         target.appendChild(newElement);
  26.     }
  27.     };
  28.  
  29.     ajaxLoadOptions(source, callback);
  30. }
  31.  
May 10 '07 #3
dmjpro
2,476 2GB
if you know the contens of combo box then it is right....
but if you want to update the list from database then it is better to use AJAX.

kind regards.
May 10 '07 #4
If you want it to fetch data from database into second combox box you'd need to self-load the form with the selected value of first combo-box.

For this you can use this property:

<form id="myForm" method="get">
<select name="FruitCategory" onchange="document.getElementById('myForm').submit ()">


where myForm is ID of the the form. Also don't forget to GET the selected value of the combo-box which on self-reload would now receive the selected value.

Once you got the selected value in your reloaded GET. You can use that value to fireyour SQL query with that value as one of the inputs.

I hope it helps.

Ankit
May 10 '07 #5
dmjpro
2,476 2GB
u can do it of course by submitting the page.

but if u use AJAX then u need not to reload the page fully.... only update the changes u want ....

kind regards.
May 10 '07 #6
avr1983
10
Thank You for your reply.........I will try the code.
May 11 '07 #7
avr1983
10
hi,

Please help me in writing the html code for second combo box and where it should be placed..................
May 11 '07 #8
acoder
16,027 Expert Mod 8TB
hi,

Please help me in writing the html code for second combo box and where it should be placed..................
See this link
May 11 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: vgrssrtrs | last post by:
<html> <head> <script language="JavaScript"> <!-- /* *** Multiple dynamic combo boxes *** by Mirko Elviro, 9 Mar 2005 *** ***Please do not remove this comment
1
by: Mohammed Mazid | last post by:
Basically I want to store the answer of a single-choice question (where candidate selects one answer) and multiple-choice question (where candidate selects more than one answer). I would like to...
3
by: arthur-e | last post by:
Thanks in advance!! I've looked at fConcatFld but that doesn't seem to be what i'm looking for or I just can't figure it out. I'm trying to have a button select records based on two combo boxes -...
0
by: Greg Strong | last post by:
Hello All, In the past I've used a combo box with the 'row source' being an Access SQL union query to select "All" or 1 for only 1 criteria in a query. An example is as follows: SELECT 0 As...
10
by: motessa | last post by:
Hello All, I am new to Access and have been looking for answers to my problem on the internet and have not found it yet. I hope someone can give me a hint. Thanks so much. I have a form...
23
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application...
4
by: Mike L | last post by:
Currently, when the user presses a letter key the combo box will go to the first item in the collection of the combo box starting with that letter. For example user presses on "R", and "R2F"...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
4
by: Swinky | last post by:
I am trying to make a combo box dependent on a text box. I cannot get the combo box to pull the related data from the text box. I have been all over this user group & have tried several versions...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.