ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 5th, 2003, 07:58 PM
bews bews is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Australia
Posts: 13 bews User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
multiple drop downs in a form

ok .. basically what im trying to do is create a form to submit some data to an access db.

In the form i want to be able to have two dynamically populated drop downs (so if a user chooses cars in the first field it comes up with a bunch of car manufacturers, or if he chooses boats it comes up with boat builders etc etc.)

Ive searched high and low, and i the best i can find is javascript to make the drop dows. The java script however uses a form to repost the data back to the page to populate the second drop down. This wont work when its inside a form.

So my question is, can this be done? and if so how? id appreciate any help i can get

Reply With Quote
  #2  
Old October 6th, 2003, 01:10 PM
dbogey dbogey is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 4 dbogey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
URL

Reply With Quote
  #3  
Old October 6th, 2003, 03:47 PM
bews bews is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Australia
Posts: 13 bews User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thats kinda what i wanted.. but i was hoping for something that i could populate from a database

thanks for the quick reply .. i think im at the stage where i might just have to use this sort of script

Reply With Quote
  #4  
Old October 6th, 2003, 04:03 PM
aspman aspman is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Ashburn,VA
Posts: 105 aspman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 22 m 40 sec
Reputation Power: 6
I load my combos using a javascript and XML dynamically. *No page refresh.* But it needs two files. There could be a little bit of maintanace hassle due to the large number of files.

One is your interface file and the other that fetches the data in XML format. I have already given that out in this forum.

I can show you how to if you are interested.

-aspman
__________________
If you ask a question you are a fool for a second. But if you dont ask, you are a fool for a life time.

Reply With Quote
  #5  
Old October 6th, 2003, 04:05 PM
bews bews is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Australia
Posts: 13 bews User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
aspman... that would be great

where abouts did you post it so i can go check it all out??

Reply With Quote
  #6  
Old October 6th, 2003, 04:41 PM
aspman aspman is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Ashburn,VA
Posts: 105 aspman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 22 m 40 sec
Reputation Power: 6
I could not find the post. I would repost it for your convenience.

here is what it looks like in the client.

Code:


function populateCombo() {

  var cbopad = 0;
  if(form.combo1.value > 0) {
    XMLDataisland.async = false;
    XMLDataisland.SRC = "/<%=approot%>/data/yourpagewithxmloutput.asp?id=" + value;
    var vals = XMLDataisland.getElementsByTagName("z:row");
    if(vals.length > 0) {
      
      if(vals.length > 1) {
        form.combo2.options[0] = new Option("-Select One-",0);
        cbopad = 1;
      } 
      for(var i=0; i < vals.length; i++) {
        form.combo2.options[i+cbopad] = new Option(vals.item(i).attributes(1).text , vals.item(i).attributes(0).text);
      }
    } else {
      form.combo2.options[0] = new Option("N/A          ",0);
    }
  }
}


and in your body section of the html/asp page

Code:
<XML ID="XMLDATAISLAND"></XML>



as far as the server page is concerned here is what you need to do inorder to get the recordset as an xml string

Code:

function getXMLstr(strSQL, cnn)
	  on error resume next
	dim oStr, oRS, oCon, strConn, oops
	Response.Write("<?xml version='1.0'?>" & vbCrLf)
		set oCon = getConnection(cn)
	  set oRS = server.CreateObject("ADODB.Recordset")
	  oRS.Open strSQL, oCon
	  set oStr = Server.CreateObject("ADODB.Stream")
	  oStr.Open
	  oRS.Save oStr, 1
	  if err.number = 0 then
	    getXMLData = oStr.ReadText
	  else
	    err = "<xml>"
	    err = err & "<error>Query Execution failed.  Check your connection parameters and query .</error>"
	    err = err & "</xml>"
	    getXMLData = err
	  end if
	  oStr.Close
	  set oStr = nothing
	  oRS.Close
	  set oRS = nothing
end function

Pass the sql query and connection to this function
Code:
sqlstring="select * from foo"

response.write getxmlstr(sqlstring,connectionstring)  


you should be all set

Reply With Quote
  #7  
Old October 6th, 2003, 04:44 PM
bews bews is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Australia
Posts: 13 bews User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanks for that .. ill see what i cant break =)

Reply With Quote
  #8  
Old October 6th, 2003, 05:35 PM
bews bews is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Australia
Posts: 13 bews User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
sorry to hassle you aspman, but ive given it a shot and i dont really know what im doing. I dont really know enough about all this to make it work. Whats started off as a simple thing has now gone past what i know.

Do you think you could tell me what pages what goes on and where i put the combo boxes etc. im confused as hell and dont know what im doing now

Reply With Quote
  #9  
Old October 6th, 2003, 06:21 PM
unatratnag unatratnag is offline
Average Intelligence
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2003
Location: Ohio/Chicago
Posts: 678 unatratnag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 22 sec
Reputation Power: 6
Send a message via AIM to unatratnag
it'd be easiest just to refresh the page

is there anything that's limiting you from that?

Reply With Quote
  #10  
Old October 6th, 2003, 06:23 PM
bews bews is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Australia
Posts: 13 bews User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
how do you mean refresh the page??

how will that populate a second drop down??

this is alot more complex than origianlly though

Reply With Quote
  #11  
Old October 6th, 2003, 06:37 PM
unatratnag unatratnag is offline
Average Intelligence
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2003
Location: Ohio/Chicago
Posts: 678 unatratnag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 22 sec
Reputation Power: 6
Send a message via AIM to unatratnag
check this out, you put on onchange='myform.submit();' in the drop down box. Once it submits you do your queries like usual for the first drop down right? Then for the second one, request.form("dropdown1") will have a value, you query the db for select * from table where column = ' request.form("dd1")' and bam, that's the recordset you populate the second drop down menu with, it's really that easy, just awkward at first.

Reply With Quote
  #12  
Old October 6th, 2003, 06:52 PM
bews bews is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Australia
Posts: 13 bews User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
unatratnag, as i said before, im really getting out of my depth here, this is getting past what i know, is there any chance of you giving me a working demo of this or pointing me to it .. i really am struggling to get my head around this at the moment *bangs head on desk*

thanks for the help

Reply With Quote
  #13  
Old October 6th, 2003, 08:16 PM
unatratnag unatratnag is offline
Average Intelligence
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2003
Location: Ohio/Chicago
Posts: 678 unatratnag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 22 sec
Reputation Power: 6
Send a message via AIM to unatratnag
well, you have two drop downs right, for the second one you have to query the database where you say "SELECT * from TABLE", now you just add this before the querystring

Code:
strSQL = "SELECT * from TABLE"
if request.form("nameofdropdown1") <> "" then
     strSQL = strSQL & " WHERE type = '" & request.form("nameofdropdown1") & "'"
end if


and that's all you have to change for the query.

in drop down box one you say
Code:
<select onchange="nameofyourform.submit();">

and that's it for autosubmitting for drop down 1, you can do the same thing for the other drop down if the user selects that one first.

Reply With Quote
  #14  
Old October 7th, 2003, 07:48 AM
dbogey dbogey is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 4 dbogey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Why make the unecessary round trips to the server using asp? As long as the data is static (not changing) trying using javascript.

daniel

Reply With Quote
  #15  
Old October 7th, 2003, 08:50 AM
dbogey dbogey is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 4 dbogey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Why make the unecessary round trips to the server using asp? As long as the data is static (not changing) trying using javascript.

daniel

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > multiple drop downs in a form


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump