473,840 Members | 1,552 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Could we retrieve the value from a populated pull down menu and reuse that value

46 New Member
Hello Experts.

Is it possible to retrieve the value from a populated pull down menu from a database and then use that value to access the same database to get the related fields.


Example:

Database name: sp
Table: importer
Field names: imp_code, imp_name, imp_address, imp_tel

My Codes:

Expand|Select|Wrap|Line Numbers
  1.  <% 'access adatabase and retrieve field to be displayed on pull down menu%>
Expand|Select|Wrap|Line Numbers
  1. <% dim adocon, adorst, strSQL
  2.  
  3. set adocon = server.createobject("ADODB.connection")
  4. adocon.open" Provider = Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath ("sp.mdb")
  5.  
  6. set adorst = server.createobject("ADODB.recordset")
  7.  
  8. strSQL="SELECT * FROM importer"
  9. adorst.open strSQL, adocon
  10. %>
[code]

<Form name="hello" id="hello">
<SELECT name="impcode" onChange="Valid ate();">
<%

Do while not adorst.EOF
%>
<option><%=ador st.Fields("imp_ code")%>
<%
adorst.movenext
loop
adocon.close
adorst.close
%>
</option>
</SELECT>
</Form>




Expand|Select|Wrap|Line Numbers
  1.  <% 'access the database again through the selected imp_code and retrieve all related fields to be displayed on text boxes in another form%>
Expand|Select|Wrap|Line Numbers
  1. <% dim adocon1, adorst1, strSQL1
  2.  
  3. set adocon1 = server.createobject("ADODB.connection")
  4. adocon1.open" Provider = Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath ("sp.mdb")
  5.  
  6. set adorst1 = server.createobject("ADODB.recordset")
  7.  
  8. strSQL1="SELECT * FROM importer WHERE imp_code=***please. This i don't know how to code, may be we can get the value from the <javascript function Validate>"
  9.  
  10. adorst.open strSQL, adocon
  11.  
  12. Response.write"<input name="impname" value=[***please. this i don't know]>"
  13. Response.write"<input name="impaddress" value=[***please. this i don't know]>"
  14. Response.write"<input name="imptel" value=[***please. this i don't know]>"
  15.  
  16. adocon.close
  17. adorst.close
  18.  
  19. %>

Expand|Select|Wrap|Line Numbers
  1. <script language="javascript" type="text/javascript">
  2. function Validate()
  3. {
  4. document.hello.impcode.value=document.hello.impcode.options[document.hello.impcode.selectedIndex].value
  5. }
  6. </script>
  7.  

Waiting eagerly for your suggestion ...........

Thanks

Giandeo
Jan 30 '08
21 2915
CroCrew
564 Recognized Expert Contributor
Hello giandeo,

I modified my example code above to meet your new requirements.

Hope this helps~

Expand|Select|Wrap|Line Numbers
  1. <%
  2. Set Conn = Server.CreateObject("ADODB.Connection")
  3.     Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("sp.mdb") 
  4.     Set rsList = Server.CreateObject("ADODB.Recordset")
  5.     SQL = "SELECT FieldOne, FieldTwo, FieldThree FROM TheTable"
  6.     rsList.CursorType = 1
  7.     rsList.LockType = 3
  8.     rsList.Open SQL, Conn
  9. %>
  10. <html>
  11.     <head>
  12.         <title>Example</title>
  13.         <script language="JavaScript">
  14.             var FieldOneArray = new Array(<%=rsList.RecordCount%>);
  15.             var FieldTwoArray = new Array(<%=rsList.RecordCount%>);
  16.             var FieldThreeArray = new Array(<%=rsList.RecordCount%>);
  17.                 <%i = 0%>
  18.                 <%Do Until (rsList.EOF)%>
  19.                     FieldOneArray[<%=i%>]='<%=Replace(rsList("FieldOne"), "'", "\'")%>';
  20.                     FieldTwoArray[<%=i%>]='<%=Replace(rsList("FieldTwo"), "'", "\'")%>';
  21.                     FieldThreeArray[<%=i%>]='<%=Replace(rsList("FieldThree"), "'", "\'")%>';
  22.                     <%i = (i + 1)%>
  23.                     <%rsList.MoveNext%>
  24.                 <%Loop%>
  25.  
  26.             function UpdateValues()
  27.             {
  28.                 var NotFound = true;
  29.                 for (x in FieldOneArray)
  30.                 {
  31.                     if (FieldOneArray[x] == document.xForm.FieldOne.value)
  32.                     {
  33.                         document.yForm.FieldOne.value = FieldOneArray[x];
  34.                         document.yForm.FieldTwo.value = FieldTwoArray[x];
  35.                         document.yForm.FieldThree.value = FieldThreeArray[x];
  36.                         NotFound = false;
  37.                     }
  38.                 }
  39.  
  40.                 if (NotFound){alert("Not found!");}
  41.             }
  42.         </script>
  43.     </head>
  44.     <body>
  45.         <form method="post" action="#" name="xForm" id="xForm">
  46.             Search Field One: <input type="text" name="FieldOne">&nbsp;
  47.             <input type="button" value="Find" onclick="UpdateValues();">
  48.         </form>
  49.         <form method="post" action="#" name="yForm" id="yForm">
  50.             <br>Field One: <input type="text" name="FieldOne">
  51.             <br>Field One: <input type="text" name="FieldTwo">
  52.             <br>Field One: <input type="text" name="FieldThree">
  53.         </form>
  54.     </body>
  55. </html>
  56.  
Feb 19 '08 #21
giandeo
46 New Member
Sir, sorry to bother you again.

I wish to display the above text fields not through a populated pull down menu but through an input text field.

Meaning that when the user key-in a value in the input text field and presses on the submit button, the FieldOne, FieldTwo and FieldThree are populated and the value input by the user still visible.

Please Sir, Help me out of this trouble
Sir, your solution is amazing. It works perfectly well. thank you so much.

Just a last but not the least bit of advice please.

When the input field is blank and on pressing enter, the message Not Found is displayed.

I wish to display this message when the input field is blank. But when the field length is less or greater than the maximum length(e.g 8), I also wish to display a message like that Invalid Input.

Could you advise me please..
Feb 21 '08 #22

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

Similar topics

3
11240
by: julian | last post by:
hi I was wondering if anyone can help me out on this.... I have dynamcally populated a drop down menu with data from an access database using ASP. The values seem fine, however when i pass them to the next page (using form get method) the whitespaces in the values are ignored. For example with <option value=jim jones> then only "jim" gets passed to the next page not "jim jones". I have viewed the source created on the dynamic page and...
1
1512
by: NEUE | last post by:
Hello, I'm trying to have a layer appear on top of a simple pull-down menu, but in IE6 the pull-down menu always appears on top. Even if I put the pull-down in a layer under the other layers, it shows on top. On Firefox and all Mac browsers is fine. Any way around this? Thanks NF
5
5385
by: judiphuongtu | last post by:
I am trying to create an input form with a pull-down menu that allows a user to add an item to the pull-down. I don't want the page to refresh when I refresh the pull-down since there's entries on the form already. Please help! Thanks. jptu
1
3802
by: BuddyWork | last post by:
Hello, When a particular user (has administrator rights) on a Windows 2000 Server SP4 tries to run any MSI's we get the message mentioned in the subject. If we logon with another user that has administrator rights then it works, if we create a new administrator user then it does NOT work, Here is the MSI log, please help as this is causing problems as only 3 users on this box are able to run MSI where are about 15 other users
7
1947
by: Smithers | last post by:
I have a non trivial ASP.NET Web application that implements its navigation system via a user control (menu.ascx) placed on every page. It is important to note that the user control that hosts the menu is injected into every page at runtime when the page is requested (i.e., it's not declared in any ASPX). The user control contains a menu that is dynamically populated and styled at runtime (fwiw: it's ComponentArt's Menu for ASP.NET -...
2
4559
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was set to...it is set to false. Can someone show me what I am doing wrong and tell me the correct way? Thank you. In the page load event, I am doing the following:
2
3108
by: Keith Burns | last post by:
Hi, I have seen two entries in the archives for this topic: 1. Uses hypertext, not a pulldown menu to feed parameters back to the python CGI 2. The other actually used Java. Is there a way using Python for CGI such that when a user selects an item from one pull down menu (ie FRUIT or VEGETABLE or MEAT) that another pull
1
1698
by: dkimbrell | last post by:
Hi there, I'm very novice to web design. I'm trying to make a pulldown menu, but the formatting keeps getting screwed up when you roll the mouse over it. Please see www.boundarysys.com for what I'm talking about. Before the mouse touches the pulldown, the vertical height of the menubar is perfect. As soon as the mouse rolls over it, it expands to about twice the height.
1
3058
by: azeemqaiser | last post by:
Hi All, I have a form with two drop down controls. I want to change the values of Drop Down Menu 2 if i select some value in Drop Down Menu 1. Like If i select country then all the states of this country should get populated in the second menu. Will appreciate your help.
0
9861
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
10924
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...
0
10605
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10301
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
9444
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
5685
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4498
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
2
4078
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3139
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.