473,405 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Dynamically populating a drop down list.

Hi Folks,

I have a question regarding binding dropdown list values. I have a set of names which i will be adding to a drop down list box. While the user selects an item from dropdown list, the person's email address should automatically come up in the text box next to it.

Name(Dropdown items) Email
1. John John.xxx@example.com
2. Adam Adam.yyy@example.com
3. Ramesh Ramesh@example.com

Please help/guide me so as how to achieve this requirement. Thanks in advance!!

Regards,
Chandhseke
May 10 '10 #1
5 3199
Dormilich
8,658 Expert Mod 8TB
If you have something like
Expand|Select|Wrap|Line Numbers
  1. <select id="email">
  2.     <option value="John.xxx@example.com">John</option>
  3. // …
  4. </select>
you can simply use a function to write the values to the text box.
Expand|Select|Wrap|Line Numbers
  1. function passAddress()
  2. {
  3.     document.getElementById("textboxid").value = this.value;
  4. }
  5. document.getElementById("email").addEventListener("change", passAddress, false);
  6. // use cross-browser event handling for IE …
May 10 '10 #2
Thank you!!. Since we are using javascript function to populate the Email address to text box, is there any drawbacks like buffering issue. Since sometimes in my code all the drop down values will get vanished off during approval process(Same page will be sent to different people based on number of levels).

Please comment on this?

Regards,
Chandhseke
May 10 '10 #3
Any update on my above thread? Please advise.

Regards,
Chandhseke
Jul 23 '10 #4
Dormilich
8,658 Expert Mod 8TB
I do not understand the problem …
Jul 23 '10 #5
Hi,

As per the above conversation we had couple of months before, i used the same techinique in order to develop a dynamic drop down list by binding the dropdown values. The initial requirement was if an end user selects an item from dropdown then its his/her email address should automatically pop-up in the text box. Please find the below code.

//JavaScript to popup email address in a text box based on item selected from a drop down list.
Expand|Select|Wrap|Line Numbers
  1. function addit()
  2.     { 
  3.         document.getElementById("Category_Email").value = document.getElementById("CatProcDir").value;
  4.         document.getElementById("HidCatProcDir").value = document.getElementById("CatProcDir").options[document.getElementById("CatProcDir").selectedIndex].text;
  5.     }
  6.  
  7. function addEmail()
  8. {
  9.     document.getElementById("OG_Email").value = document.getElementById("OGC_Name").value; 
  10.     document.getElementById("HidOG_Email").value = document.getElementById("OGC_Name").options[document.getElementById("OGC_Name").selectedIndex].text;
  11. }
  12.  
//Actual ASP/HTML code

Expand|Select|Wrap|Line Numbers
  1. <%@ Language = VBScript %>
  2. <% Response.Buffer = true %>
  3. <html>
  4. <head>
  5. <title>Supplier Decision Summary</title>
  6. </head>
  7. <body bgcolor="#666666">
  8. <form action="SQLInsert.asp" method="post"  name="SDS_step_one" onsubmit="return validate()">
  9. <tr>
  10.        <td colspan="2" style="height: 32px">Regional/Category Procurement Director </td>
  11.        <td colspan="3" style="width: 999px; height: 32px;">
  12.       <select name="CatProcDir" id="CatProcDir" style="width: 242px" onchange="addit()">
  13.        <option value="">Select</option>
  14.        <option value="Chris.Jacob@au.unisys.com">(APAC)Jacob, Chris </option>
  15.        <option value="Dave.McAdam@au.unisys.com">(APAC)McAdam, Dave</option>
  16.        <option value="tony.o'connor@gb.unisys.com">(EMEA)O’Connor, Tony </option>
  17.        <option value="Graham.Chalmers@gb.unisys.com">(Global)Chalmers, Graham</option>
  18.        <option value="Martin.Sturla@unisys.com">(LACR)Sturla, Martin</option>
  19.        <option value="Christopher.Bowe@unisys.com">(NA)Bowe, Chris</option>
  20.        <option value="Jay.McKeever@unisys.com">(NA)McKeever, Jay</option>
  21.        <option value="mark.pagliaro@unisys.com">(NA)Pagliaro, Mark</option>
  22.     </select>-->
  23.        <select name="CatProcDir" id="CatProcDir" style="width: 242px" onchange="addit()">
  24.        <option value="">Select</option>
  25.         <%
  26.         SQLCatProc = "Select * from SDS_ProcApprovers where Deleted = 'No' Order By Cat_Proc_Name ASC" 
  27.         Set Rs1 = oConn.Execute(SQLCatProc)
  28.         Do Until Rs1.EOF
  29.         %>
  30.         <option value="<%=Rs1("Cat_Proc_Email")%>"><%=Rs1("Cat_Proc_Name")%></option>
  31.         <%
  32.         Rs1.MoveNext
  33.         loop
  34.         Rs1.close
  35.         %>
  36.        </select>
  37.        </td>
  38.  
  39. </td>
  40.        <td colspan style="height: 32px"><input type="text" name="Category_Email" style="width: 250px" />
  41.        <input type="hidden" name="HidCatProcDir" value="" />
  42.        </td>
  43.        </tr>
  44. <tr>
  45.        <td colspan="2">OGC Contact</td>
  46.        <td colspan="3" style="width: 999px">
  47.        <select name="OGC_Name" onchange="return addEmail()" style="width: 240px">
  48.        <option value="">Select</option>
  49.        <%
  50.         SQLOGC = "select * from OGC_Contact Where Deleted = 'No' order by OGC_Contact ASC" 
  51.         Set Rs1 = oConn.Execute(SQLOGC)
  52.         Do Until Rs1.EOF
  53.         %>
  54.         <option value="<%=Rs1("OGC_Email")%>"><%=Rs1("OGC_Contact")%></option>
  55.         <%
  56.         Rs1.MoveNext
  57.         loop
  58.         Rs1.close
  59.         %>
  60.        </select>
  61.        </td>
  62.        <td colspan="3" style="width: 1259px"><input type="text" name="OG_Email" id="OG_Email" style="width: 250px" maxlength="100"/>
  63.        <input type="hidden" name="HidOG_Email" value="" />
  64.        </td>
  65.        </tr>
  66.  <input id="Submit" style="width: 180px" type="submit" value="Submit" onclick="document.SDS_step_one.Submitform.value = 'Submitted'"/>
  67.  <input type="Submit" value="Save and Submit Later" name="Save" onclick="document.SDS_step_one.Submitform.value = 'Saved'"/>
  68. </table>  
  69. </form>
  70. </body>
  71. </html>
  72.  

//SQLnew.asp in formaction will insert the form values to DB table.

Expand|Select|Wrap|Line Numbers
  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
  2. <!--#include file="Connection.asp" -->
  3.  
  4. <%
  5. Select Case Trim(Request.Form("Submitform"))
  6.     Case "Submitted"
  7. SQLAdd = "Insert into SDS (Last_Update, Scope, Category, Sourcing_Methodology, OGC_name, Approval2alt, Category_MGR, Approval3alt, Proc_Director, Approval6alt )" & _
  8.          "Values ('" & Today & "','" & Scope & "','" & Category & "','" & Source_method & "','" & HidOG_Email & "','" & Com_Email & "','" & HidCom_Email & "','" & OG_Email & "','" & HidCatProcDir & "','" & Category_Email & "')"
  9.  
  10. oConn.Execute SQLAdd
  11.  
This form carries these data to 9 approvers for approval, but sometimes data in the drop down list will get disappeared automatically(both in form/DB).

Please help if there is anything that needs to be corrected in my code. THis is a old application therefore old technology being used.

Regards,
Chandhseke
Jul 26 '10 #6

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

Similar topics

1
by: Jonny Tango | last post by:
Hello everyone. Q. How do I create a dynamically-generated drop-down list for use in an array. I'm using PHP with a MySQL database (through phpMyAdmin) My database table is called...
1
by: jonnytansey2 | last post by:
Can anyone out there give me a pointer regarding creating a dynamically-generated drop-down list connected to an array? And is that question as clear as chocolate spread? Here's what I've got....
4
by: Chris Geier | last post by:
string strLdap = "LDAP://OU=Sales,DC=Company,DC=com" DirectoryEntry objOU = new DirectoryEntry(strLdap); DirectorySearcher objUserSearcher = new DirectorySearcher(objOU); SearchResultCollection...
1
by: msnews.microsoft.com | last post by:
I'd like to hear your thoughts on best methods for populating drop down list controls. I have states and countries drop down lists that don't change often, so naturally I "hard code" them in the...
13
by: Leszek Taratuta | last post by:
Hello, I have several drop-down lists on my ASP.NET page. I need to keep data sources of these lists in Session State. What would be the most effective method to serialize this kind of data...
2
by: Yoshitha | last post by:
hi I have 2 drop down lists in my application.1st list ontains itmes like java,jsp,swings,vb.net etc.2nd list contains percentage i.e it conatains the items like 50,60,70,80,90,100. i will...
5
by: mc | last post by:
I've got three controls on a page a Drop Down List, a List Box and a Button I've added 3 items to the Drop Down List I have added some code in the Button onClick Event Handler, as below...
3
by: Yi Chen | last post by:
We have a drop down list on a PHP page, with several product names, and when people click one item, we will refresh the same page with the product name as parameter, and in turn we want to include...
5
by: mrtr33 | last post by:
I have a class table where I want to access the names of courses and the description of each course. The names of the courses go in a drop down list. Based on the user selection, the description...
3
by: DaveRook | last post by:
Hi I am using C# and Access databse for a web site. I have a drop down list which I need to populate dynamically according to results in a database. Example There will be 1 drop down list...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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...
0
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...

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.