Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fill combo depending on info in the other 2

Status
Not open for further replies.

rtshort

IS-IT--Management
Feb 28, 2001
878
US
I have a lot of ComboBoxes on a page for information on an engine. I want the next ComboBox in line to be filled out according to the current ComboBoxes choice. I would also like to accomplish this with VBScript. Any ideas? Rob
Just my $.02.
 
are you gonna submit the page after every choice? then it is pretty simple. if you want to pass all the data to the client and then do it there, it gets more complex. from the sound of it, there would be a lot of data, making the load time longer, also VBscript would only work on IE browsers.

depends on what you are planning.

hth
Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
I'm all ears on any method, although it would seem to be better to not submit the form after each ComboBox. Would Remote Scripting work for this. I don't know if it can be used with VBScript or not. I don't know to much about it. I found some info on the MSDN site, but it's not too clear. Only working on IE 4.0 or greater is fine with me, but I did read somewhere that there was or is going to be a VBScript plugin for Netscape?

Everything you haven't ever tasted does tast like chicken according to whomever cooked it doesn't it. LOL

Thanks for the reply. Rob
Just my $.02.
 
remote scripting is a possibility, though most mentions of are that it is extremely compplex and slghtly cumbersome to program. I believe it uses javascript.

As for the submit everytime, this is the way the IBM site works, so it is really up to you.

hth

bastien Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
remote scripting is a possibility, though most mentions of are that it is extremely compplex and slghtly cumbersome to program. I believe it uses javascript.

As for the submit everytime, this is the way the IBM site works, so it is really up to you.

one of the better books on remote sripting is "Windows Web SCripting Developers Guide" osbourne press

hth

bastien Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
Just another option - if interested

This link will show you a way to use JavaScript with your asp page to make dynamic dropdowns that do not require the page being reloaded. Its a strip down version of what I use but you will see how you can add new arrays and dropdowns to extend as far as you like.

hope it is of some help
 
I have the following code in the Click Event of the ComboBox:

<%
Dim sql, cn, rs
%>

<%
Set cn = Server.CreateObject(&quot;ADODB.connection&quot;)
Set rs = Server.CreateObject(&quot;ADODB.RecordSet&quot;)
cn.ConnectionString = &quot;Driver=SQL Server;uid=sa;pwd=;Server=RobHome;Database=Mistep&quot;
cn.Open
sql = &quot;Select * from sysobjects where name like '&quot; & &quot;I/B%&quot; & &quot;'&quot; '& &quot;and name like '&quot; & Mercruiser & &quot;'&quot;
Response.Write (sql)
rs.open sql, cn, 3, 3
If rs.BOF = True and rs.EOF = true then
Response.Write (&quot;No record found&quot;)
Else
rs.MoveFirst
Do Until rs.EOF = True
XXXXXXXXXXXXXXXXXXX
rs.MoveNext
Loop
End If
rs.Close
Set rs = NOthing
%>


I don't know what code to put where the X's are to get the code back to my original page.

Please repost the link. I didn't see it in the above post.

Thanks Rob
Just my $.02.
 
The above code goes to another page. FillBox2.asp. Forgot that in my last post. My bad. Rob
Just my $.02.
 
Sorry about that

Here is the link I was refering to

thread333-303713 hope it is helpful
 
Can this be done in VBScript? Rob
Just my $.02.
 
Hi Rob

You could do this in VB Script but because it runs on the client side, &quot;IF&quot; cross browser compatability is an issue then it would be better to keep it in JavaScript.

 
Thanks Kevin. Do you know of an example somewhere that is done in VBScript.

I just started teaching myself how to do this about 1 1/2 years ago. I have what I set out to do completed in VB 6.0 and would like to make it a web app. So far I've learned VB 6.0, SQL Server 7.0, and IIS 5.0. What I needed to know of them anyway. Since VBScript is so close to what I already know, I'd like to stick with it and not learn a new language. I'm too old for this stuff. LOL I did bodywork for about 15 years and I'm changing careers in midlife. I was lucky enough to be hired by a very nice and caring couple who own their own business to write software for them.

If anyone knows of an example I can retrive, I would appreciate it greatly.
Rob
Just my $.02.
 
Hi Rob

Sorry for the slow response but I have been on vacation the last couple weeks. While I am sure you could do similar in VBScript I do not have and I am not aware of any readily available samples. The trick is to basically hold the values in a 3 dimensional array (You can get away with a two dimensional array if all you have is two ComboBoxes) on the client side so that you do not have to continually call on the server /reconnect to a database or reload the page etc. The Script simply loops through the arrays and populates the comboboxes based according to (ID numbers) values held in the arrays when the End User makes a selection.

Example

Array1: (Holds Countries)
1 Canada 1
2 USA 2

Array2: (holds States and Provinces)
1 Quebec 1
1 Ontario 2
2 New York 3
2 Ohio 4

Array3 (Holds Cities)
1 Montreal 1
2 Toronto 2
2 Hamilton 3
3 New York City 4
4 Cleveland 5

Notice how Ontario in Array2 is given an ID number of 2 and how that ID Number can then be used to relate to Toronto and Hamilton in Array3 ?


Hope it is of some help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top