473,569 Members | 2,383 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Textbox value change on select other item dropdownlist

Ok I got form within a c sharp page.

Situation:
On the form I have a drop downliwst and a textbox, the dropdownlist is
populated with products and the textbox has a default vale of the product
price.

Problem:
The first item prce in the dropdownlist is populated in the textbox.
When I select another product from the dropdownlist the value within the
textbox doesn't change to the price of the selected product.

Question:

Can someone tell me how let the textbox value be changed if another item is
selected from the dropdownlist without having to do a postback(which
immediatly submits the form).

Example data loaded in form:
Productname (loaded in dropdownlist) Productprice (loaded in textbox)
Chocolate chips 1,-
Strawberry 0,50

Is this only possible by building up an javascript array and not by doing
somesort of callback on the page after the ddl item has been selected?
Thanks in advance,
A

Jan 9 '06 #1
1 8521
You need to add the below javascript in ur html section of the page

<script language="javas cript">
function ShowValue()
{
document.Form1["textboxnam e"].value =
document.Form1["dropdownva lue"].value
}
</script>
and in the codebehind file add this line

Dropdowncontrol .Attributes.Add ("onchange","ja vascript:ShowVa lue()");

Now when you change the value in the drop down, the Textbox will be
filled without refreshing the page

Jan 9 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2671
by: Benton | last post by:
Hi there, I am working with ASP.NET. I have a TextBox and DropDownList (for customer info input) that I need to tie up, i.e., when the DropDownList item changes (the customer name), the TextBox should reflect the selected value (the customer number). And when a user types something in the TextBox and exits the control, the DropDownList item...
3
3459
by: RockNRoll | last post by:
Greetings, Can I select an item in a listbox based on user textbox entry and a submit button? Can you provide any code examples for what needs to occur when the user clicks submit? Thank you, -Dave
7
2099
by: I am Sam | last post by:
I have a DataGrid that is passing information to a stored procedure properly but the parameters aren't being casted properly. I was woundering if anyone can tell me how I should properly cast the following: (TextBox)UserPrefix=(TextBox)e.Item.Cells.Controls; string strUserPrefix=UserPrefix.Text; I keep getting the following error and I...
2
2173
by: Antonio D'Ottavio | last post by:
Good morning, I've a problem with a dropdownlist located inside any row of a datalist, I fill both datalist and dropdownlist at runtime, the problem is with the dropdownlist infact using the event OnItemDataBound I can fill it but it is impossible for me to load the right selectedItem.Value , infact looking at the html page produced by the...
2
11044
by: Atreju | last post by:
Ok I got form within a c sharp page. Situation: On the form I have a drop downliwst and a textbox, the dropdownlist is populated with products and the textbox has a default vale of the product price. Problem: The first item prce in the dropdownlist is populated in the textbox. When I select another product from the dropdownlist the...
0
4250
by: Zark3 | last post by:
Hi all, In a web form I use a for loop to dynamically add TextBox'es to a page (one for each item in an input file). I can get the input values and I can display them in Label's and TextBox'es. That part works. However, my problem is that the form lets the user choose from input files; the labels are updated, the textboxes are not. This seems...
1
2286
by: Ted | last post by:
Here is a stored procedure I created in MySQL: CREATE PROCEDURE `sp_find_food`( IN search_string varchar(255) ) BEGIN DECLARE ss VARCHAR(257); SET ss = CONCAT('%',search_string,'%'); SELECT NDB_No,Long_Desc FROM food_des WHERE Long_Desc LIKE ss; END
0
2390
by: Jacob Donajkowski | last post by:
Once the user logs in I want to have the users switch from the Roster View to the Profile View and enter their profile infomation and save it. Then the next time they login and go to the Profile View I want the form populated from there profile on the sql server. The code to save the profile works fine. But when the user logs back in they data...
1
3094
by: CindyH | last post by:
Hi I'm using vs.net 2003. I have a dropdownlist inside a datagrid. I would like to be able to select a value from the dropdownlist and then have a textbox which is also inside the datagrid filled with that value. I'm calling OnSelectedIndexChanged="ddlGridMonth_SelectedIndexChanged" event when an item from the dropdownlist is selected ...
0
7703
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...
0
7618
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...
0
8132
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...
1
7678
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...
0
7982
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...
0
6286
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...
0
5222
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...
0
3656
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...
0
944
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...

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.