473,799 Members | 2,834 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to populate the dropdown values from another dropdown.

24 New Member
Hii..

I Have 2 dropdowns.The first dropdown contains main products which is from database table1.
If we select The one of dropdown value then the 2 second drop down should fill with all sub products of that main products from another table2.

Ex:: pulsor is the main product which is in 1 st dropdown
pulsor 150cc,pulsor 180cc ,pulsor 180cc are the sub prod s of pulsor.
when ever we select the pulsor on 1st dropdown it should disaply all sub models. same as per all models.

These two dropdowns should fill with from database only.

Thanks
Nov 17 '09 #1
2 10624
jeffstl
432 Recognized Expert Contributor
While its been awhile since ive done classic ASP (someone please correct me if I am wrong) I don't think you can capture a OnChange event in a drop down easily.

You might have to have to submit your form to the same page and add a querystring like &submittedMain= True ...then in your page check if submittedMain=T rue and if it is then you can populate your second drop down.

Assuming you know how to populate a record set with sql you would need sql that looks something like this

Select ProductKey,Prod uctName from Products where MainProductKey = " & SelectedMainPro ductKey & "

Then once you have that data in a record set use this:
Expand|Select|Wrap|Line Numbers
  1. <form>
  2. <select size="1" name="D1">
  3. <option VALUE="0" SELECTED>Select Sub Product</option><br>
  4.  
  5. <%Do while not RS.eof
  6. Response.Write "<option VALUE=" & ProductKey & ">" & ProductName & "</option><br>"
  7.  
  8. rs.movenext
  9. loop
  10. ' Exit the loop when reaching the end of the recordset
  11. 'If rs.EOF Then Exit For end if
  12. 'next
  13. 'end if%>
  14. </select>
  15. </form>
Nov 17 '09 #2
chinni1
24 New Member
Hiii...
Thanks ur reply.I got the code.Here it is....

strquery="Selec t * from products"
<select name="selprod" ID="dd1" onchange="reloa d(this.form);">
<option value="">Select prod</option>
<%if objrs.State <> 0 then objrs.Close
objrs.Open strquery,conn,3 ,3
While Not objrs.eof
prod_id=objrs(0 )
prodname=objrs( 1)
Response.Write "<option value='" & prod_id & "' " & strSel & ">" &prodname& "</option>"
objrs.moveNext
Wend
</select>

strquery1="Sele ct * from sub_master where id="&id
%>
<select name="selprod1" ID="dd2" >
<option value="">Select sub</option>

<%if objrs1.State <> 0 then objrs1.Close
objrs1.Open strquery1,conn, 3,3
While Not objrs1.eof
prodid=objrs1(0 )
prod_name=objrs 1(2)
Response.Write "<option value='" & prodid & "' " & strSel1 & ">" &prod_name& "</option>"
%> <!-- <option value="<%=prod_ id%>" selected><%=pro d_name%></option> -->
<% objrs1.moveNext
Wend
</select>


<SCRIPT LANGUAGE="JavaS cript">
function reload(form)
{
var val=myform.selp rod.options[myform.selprod. options.selecte dIndex].value;
document.myform .method="Post";
document.myform .action="index. asp?page=list"& id="+ val
document.myform .submit();
}

Thanks...
Nov 18 '09 #3

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

Similar topics

20
12439
by: Dannyboyo | last post by:
I have what I hope is a simple request. I can't really code in javascript, but I am pretty good at cusomizing it with slight modifications. I code in ASP and HTML. I am trying to capture customer input of product names to put on custom labels we make. Some of the labels will have our product names on them, but the customer can add other products that we do not sell. So, on my product detail page I want a textbox that can have rows copied...
0
1118
by: Marc Miller | last post by:
Hi to all, (I apologize that I posted this in dotnet.languages.vb.controls, but I NEED and answer quickly, please) I have an 'employees' datagrid which contains company numbers as labels. When the user clicks 'Update', I have dropdown lists as edititems for the company numbers and populate them from a company table so that the user can change the existing company number. The problem is that the
3
7365
by: Seelan | last post by:
Hey Guys, I have read a table from SQL Server to a Dataset called ds. Now I want to list the items of one column to a DropDown List...I can do this perfectly but i want ht e list to contain DISTINCT items without having to call the SQLCommand again! Please help thanks! Seelan-
2
3630
by: Chris Becker | last post by:
This is my attempt to rephrase a question I asked earlier that got no response. I suspect it was my poor/unplanned wording. Here is another attempt: I have a form with some drop down lists. I would like the user to be able to start filling in the form, then get to one of the dropdown lists (ex: Service Type) and realize that the dropdown list does not contain the entry that they need. So next to the Service Type drop down list is a...
1
1582
by: oj | last post by:
Could anyone provide some approaches that are used to cache dropdown list control values to share globally beteween all users? Currently, each time a page is loaded all the dropdown values for each dropdown list control are retrieved from the database. I would like to go away from this approach. Any info. is appreciated.
11
13534
by: abctech | last post by:
Hi, I am developing a webapplication using Javascript,JSP,Servlets. I have 2 dropdown lists in my form, the first one is autopopulated on form load , I have written this code in Jsp and its working as well, but now I want that once a user selects an option from the 1stDD then immediately the 2nd DD should be populated depending on the selection made.... The 1stDD uses a diff table and so does the 2ndDD , however their records are tied with...
0
1274
by: Padma Athimoolam | last post by:
Hi, I am new to VB and XML.I want to populate XML Values in Excel Sheet.My Sample XML is <?xml version="1.0" encoding="UTF-8" ?> - <workbook> - <worksheet name="Scorecard_KTC_MW"> <cell name="E9" formula="=sum(G9,I9,K9)" type="text" /> <cell name="E11" formula="=sum(G11,I11,K11)" type="Number" comment="Sample Help" /> <cell name="E13" formula="=sum(G13,I13,K13)" type="General" /> <cell name="G9" value="0" type="text" />
3
2805
by: fish919 | last post by:
Hello All, I am creating a date base in access. I want to create a dropdown list box that is connected to another dropdown list box. You start with a dropdown list that has 5 choices and each of these choices will call another dropdown list box when one of the choices from the first gets selected. (I hope this makes sense) All of this is being done on a single form. I know how to make a (sub) dropdown list not seen before the action...
0
1074
by: jeccinta jeccinta | last post by:
Hi am using a grid view.I have 2 drop down lists inside gridview.one dropdownlist1 fetches country names.Based on that i should get state names in another dropdown list2.how to write code for this.Since both the drop down lists are inside grid view in asp.net using C#
0
9687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9541
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10485
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10231
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10027
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9073
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4141
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.