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 September 9th, 2003, 02:36 AM
Ben Shark Ben Shark is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 3 Ben Shark User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Dynamic Drop Down Boxes And Form Variables Retainment

Hi To All,

I was hoping that someone could help me out.

Here's my problem. I have two drop down boxes. Both need to be populated from a database.

dpd_box1
dpd_box2

When I select something from dpd_box1 I need dpd_box2 to re-populate itself from a database.

I then need to retain all the other values that have been put into some other fields on the form.

For an example I was going to use something like:

Database Name: Temp_Database

Table Name One: tbl_dropdown1

#dpd_id
dpd_name

Table Name Two: tbl_dropdown2

#dpd_id
dpd_no
dpd_name

So there is a link between dpd_id and dpd_no.

I hope I have provided enough information.

Thanks for all your help

Reply With Quote
  #2  
Old September 9th, 2003, 07:07 AM
Vlince Vlince is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Canada, Quebec, Montreal
Posts: 410 Vlince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
If you look at the bottom of your thread, you'll notice a place that says:

More Related threads

The answer was right under *your* nose!

Have a look here...
http://forums.devshed.com/t65760/s.html


Hope this helps!
Sincerely

Vlince

Reply With Quote
  #3  
Old September 9th, 2003, 04:11 PM
Ben Shark Ben Shark is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 3 Ben Shark User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi Vlince

I had a play around but still cannot get it to work. Excuse me, but i'm very new to asp and have never used javascript before. It would be much appreciated if you could outline an example with my particular database.

Thanks for your time.

Kind Regards

Reply With Quote
  #4  
Old September 9th, 2003, 06:39 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
THEORY:
in the combo box 1, onchange call document.myform.submit();
then when populating the combo boxes, if the request.form("combobox1") is equal to some value, you set it equal to that again by default, and you query the DB for table 2 where primkey = comobox1.

example
combobox 1 has:
car
motorcycle
boat

when i select boat, the form resubmits it self

when populating combobox 1 since request.form("combobox1") has a value, i write selected under the appropriate combobox, boat.

then comes combo box 2, since combo box 1 has a value, you query the DB and select * from models where type = ' request.form("combobox1")' and then you have all your second combobox2 values, and then you jsut populate it that way.

the trick is at the top of the page, you do a check for request.form("submit"), assuming you're calling your submit button submit, if it's <> "", then the user has clicked submit. This works since if it's = "", this is the first time visiting the page or it was force submitted by javascript. If it's <>"" you do whatever else you need your form to do and move on etc etc...

it's key you understand what you're doing before you fumble around trying to just get it work.

Reply With Quote
  #5  
Old September 9th, 2003, 06:49 PM
Ben Shark Ben Shark is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 3 Ben Shark User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for the quick reply.

do you have some example code that i could perhaps look at.

thanks

Reply With Quote
  #6  
Old September 9th, 2003, 07:09 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
please understand what you're doing first
Javascript
Code:
	    function refresh()
	    {
	    	//alert ("HELLO");
	    	document.myform.submit();
	    }

top of page
Code:
		if request.form("Update") = "Update" then
	                         Do update stuff here
                                          response.redirect "updated.asp"
                               end if
		<select name="D1" onchange="refresh();">
		<option value=""></option>
	strSQL = "select (requestNumber) as rn, ContactFullName as fn, dateRequested as dr, presenters as pr, " & _
		"webcastName as wn from request_received order by rn desc"
		set RS = objConn.Execute(strSQL)

		'-----------the first selection box
		RS.MoveFirst
		do while not RS.EOF
			response.write "<option "
			if request.form("D1") <> "" then
				if Cint(request.form("D1")) = RS("rn") then
					response.write "selected"
				end if
			end if
			response.write " value=""" & RS("rn") & """>"
			Response.Write "Webcast Number: " & RS("rn")
			Response.write ",     Requester: " & RS("fn")
			Response.write ",     Webcast Name: " & RS("wn")
			response.write "</option>"
			RS.MoveNext
		loop

         

autofilling in selection boxes
Code:
Please provide the following contact information:</P>
<%
			strSQL="select * from  [request_received] where requestnumber = '" & request.form("D1") & "'"
			set RS = Conn.Execute(strSQL)
			'response.write "D1: " & request.form("D1") & "<br>"
%>
<TABLE>
<TR>
<TD ALIGN="right">
<EM>Name</EM></TD>
<TD>
<INPUT NAME="Contact_FullName" SIZE=35 <% if request.form("D1") <> "" then response.write "value="""&RS("ContactFullName")&"""" end if%>">
</TD>
</TR>
<TR>
<TD ALIGN="right">
<em>Quicklook ID</em></TD>
<TD>
<input type="text" name="quicklook" size="35" maxlength="8" onBlur="emailFill();" <% if request.form("D1") <> "" then response.write "value="""&RS("quicklook")&"""" end if%>></TD>
</TR>
<TR>
<TD ALIGN="right">
<EM>Organization</EM></TD>
<TD>
<select size="1" name="Contact_Organization">
<option>Choose Option</option>
<option <% if request.form("D1") <> "" then if RS("ContactOrganization") = "CFO" then response.write "SELECTED" end if end if%>>CFO</option>
<option <% if request.form("D1") <> "" then if RS("ContactOrganization") = "Chief Marketing Officer" then response.write "SELECTED" end if end if%>>Chief Marketing Officer</option>
<option <% if request.form("D1") <> "" then if RS("ContactOrganization") = "Corporate Public Relations" then response.write "SELECTED" end if end if%>>Corporate Public Relations</option>
<option <% if request.form("D1") <> "" then if RS("ContactOrganization") = "Financial Solutions Division" then response.write "SELECTED" end if end if%>>Financial Solutions Division</option>
<option <% if request.form("D1") <> "" then if RS("ContactOrganization") = "Global Procurement" then response.write "SELECTED" end if end if%>>Global Procurement</option>
<option <% if request.form("D1") <> "" then if RS("ContactOrganization") = "Human Resources" then response.write "SELECTED" end if end if%>>Human Resources</option>
<option <% if request.form("D1") <> "" then if RS("ContactOrganization") = "IT Services" then response.write "SELECTED" end if end if%>>IT Services</option>
<option <% if request.form("D1") <> "" then if RS("ContactOrganization") = "Law" then response.write "SELECTED" end if end if%>>Law</option>
<option <% if request.form("D1") <> "" then if RS("ContactOrganization") = "Quality" then response.write "SELECTED" end if end if%>>Quality</option>
<option <% if request.form("D1") <> "" then if RS("ContactOrganization") = "Retail Solutions Division" then response.write "SELECTED" end if end if%>>Retail Solutions Division</option>
<option <% if request.form("D1") <> "" then if RS("ContactOrganization") = "Systemedia Division" then response.write "SELECTED" end if end if%>>Systemedia Division</option>
<option <% if request.form("D1") <> "" then if RS("ContactOrganization") = "Teradata Division" then response.write "SELECTED" end if end if%>>Teradata Division</option>
<option <% if request.form("D1") <> "" then if RS("ContactOrganization") = "World Wide Customer Services Division" then response.write "SELECTED" end if end if %>>World Wide Customer Services Division</option>
</select>
</TD>



that's the theory. There are things they i don't check like if it's already rs.eof first but like i said, my environment is different then yours.

Last edited by unatratnag : September 9th, 2003 at 07:16 PM.

Reply With Quote
  #7  
Old September 9th, 2003, 07:17 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
and i hope you appreciate that, i had to boot up my work pc which quite frankly scares me if i'm not working =(

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Dynamic Drop Down Boxes And Form Variables Retainment


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


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT