Textbox value change on select other item dropdownlist

A

Atreju

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
 
A

Anmol

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","javascript:ShowValue()");

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top