473,399 Members | 3,401 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,399 software developers and data experts.

Selecting a value of ASP:DropDownList to concatenate with another String in a textbox

24
Hi all. I need help about this particular aspect.

In a webform I have an <asp:textbox> (txtName) and <asp:DropDownList> (lstSchool) with 2 values inside.

I have typed in a value for the textbox. When I select an option from the dropdownlist, I would like that value(String) to be concatenated with the textbox's value. How do I achieve this in JavaScript?
(Microsoft Visual Studio 2005)

Any help/advice appreciated. Thanks.
Jan 8 '09 #1
6 3537
pronerd
392 Expert 256MB
@uicouic
Expand|Select|Wrap|Line Numbers
  1.  
  2. <html>
  3.     <body><br /><br />
  4.  
  5.         <select onchange="concatInput()" id="dropDownMenu" >
  6.             <option value="1" >1</option>
  7.             <option value="2" >2</option>
  8.             <option value="3" >3</option>
  9.         </select>
  10.  
  11.         <br /><br />        
  12.  
  13.         <input type="text" id="feildInput" />
  14.  
  15.  
  16.         <script>
  17.            function concatInput() {
  18.  
  19.                 var fieldOne = document.getElementById('dropDownMenu');
  20.                 var fieldTwo = document.getElementById('feildInput');
  21.                 var conCatinatedVal = fieldOne[fieldOne.selectedIndex].value  + fieldTwo.value;
  22.  
  23.                 alert('  New Contactinated String : '+conCatinatedVal);
  24.  
  25.             }
  26.         </script>
  27.     </body>
  28. </html>
  29.  
  30.  
Jan 9 '09 #2
uicouic
24
I appreciate your response but Im not sure what you mean by that, since Im not using HTML tags for the dropdownlist, Im using <asp:DropDownList> instead. Could you advise me on how to modify the above code? Thanks.
Jan 14 '09 #3
acoder
16,027 Expert Mod 8TB
If you check the source of the generated code, you will see that it's converted to HTML.
Jan 14 '09 #4
uicouic
24
Bummer I can't get it work. :(
Do I need to assign an attribute to the DropDownList so I can call the function? e.g.

Expand|Select|Wrap|Line Numbers
  1. lstBox.attributes.add("onchange","concatInput( )")
or is there another way going about it?

Please advise, thanks.
Jan 15 '09 #5
acoder
16,027 Expert Mod 8TB
Yes, that seems to be the way. If you still have problems with it, try asking in the ASP.NET forum.
Jan 15 '09 #6
uicouic
24
Ok I'll do just that.

Thanks acoder. :)
Jan 16 '09 #7

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

Similar topics

0
by: C | last post by:
Hi, I have a drop down on my aspx as below. In between my opening and closing tags I render out the Items by populating a variable with the items. <asp:DropDownList id="selProf"...
1
by: Thierry | last post by:
Hi, Is it possible to get the value of an asp:dropdownlist in javascript. I need to get that value to assign it to a hyperlink. This does not work:...
0
by: Luis Esteban Valencia | last post by:
am trying to databind within an asp:textbox control. I have tried many variations found here but nothing seems to work. It works fine if I use a regular HTML textbox input though. Here is what I...
3
by: Patrick | last post by:
Try to put in a TextBox next month's date in format (MMM yyyy). The following does NOT work, why is that? <!--When rendered, the texbox is blank, although the text in the round bracket after the...
0
by: datakix | last post by:
After 16 hours of frustration, I've managed to solve this problem for a project I'm working on. The 'trick' is set EnableViewState="False" for the asp:textbox inside the Repeater control. The...
0
by: Barb | last post by:
How can I limit the number of items that show up in a dropdown list at one time? I have a list of states, and because my dropdown list is near the bottom of the page, it becomes a drop-up list. ...
2
by: John Smith | last post by:
I have this DataGrid: <asp:datagrid id="dg1" runat="server" AutoGenerateColumns="False"> <Columns> <asp:TemplateColumn HeaderText="SM"> <ItemTemplate> <asp:Label id="Label2" runat="server"...
0
by: den 2005 | last post by:
Hi everybody, I created a Gridview with a TemplateField and there is Label control in ItemTemplate and a DropdownList control in EditItemTemplate, I was to displayed them ok when I click the...
0
by: sjickells | last post by:
Hi I am having a problem using asp:TextBox's in a transparent table. I have a background image on the page and a table in the middle of the page. I have set the background colour of the table...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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
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
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,...
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.