By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,354 Members | 907 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,354 IT Pros & Developers. It's quick & easy.

Textbox value change on select other item dropdownlist

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
You need to add the below javascript in ur html section of the page

<script language="javascript">
function ShowValue()
{
document.Form1["textboxname"].value =
document.Form1["dropdownvalue"].value
}
</script>
and in the codebehind file add this line

Dropdowncontrol.Attributes.Add("onchange","javascr ipt:ShowValue()");

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

Jan 9 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.