Implementing a dynamic drop down list box in a web form control in C#

Dear Expert,
   I am developing a web form in C# which has a drop down list box that contains units of measure, i.e. in, ft, mm, m, and km. I have set the selected value to inch. Here is the scenario. Say the end user enters a value of 10 inside the corresponding text box. When the end user changes units to any other unit like mm the conversion works fine, showing the value 254 mm. How do I make this flexible so that if the end user decides to select a unit of measure for example mm, but doesn't want the converted mm value, which in this case is 10 inches, instead the end user wants to override the converted value  25 mm by changing the textbox value. If the end user wants to convert this newly entered value to say meters, it should just be a matter of selecting that from the drop down list box and displaying the value .025 m.
  I guess my question would be how do I keep track of the previous selected value at the same time keeping track of the newly selected value to provide for the correct conversion.

Regards,

-K
Khopkins32Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

COBOLdinosaurCommented:
Just keep the last selectedIndex in a hidden input.  Then pass the old value from the hidden field and the new index value to the calculation function:

<form>
<input type="hidden" name="last" value="0">
<input type="text" name="Userin">
<select
onchange="yourcalc(parseInt(this.form.last.value),this.selectedIndex);this.form.last.value=this.selectedIndex)
<option>.....

Cd&
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Khopkins32Author Commented:
Thanks vervy much Coboldinosaur
-K
0
COBOLdinosaurCommented:
Glad I could help.  Thanks for the A. :^)

Cd&
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.