Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Other Development Tools
 Combo Box in ASP

Author  Topic 

Brittney10
Posting Yak Master

154 Posts

Posted - 2011-03-15 : 09:51:11
Is there a way to autofill a text field, based on the value in a combo box? The two should be matching. I'm using ASP.Net/Visual Studio 2010.

ajthepoolman
Constraint Violating Yak Guru

384 Posts

Posted - 2011-03-15 : 10:21:23
Can you capture the SelectedIndexChanged event on the combobox and then grab the SelectedValue property of the combo to set the Text value of the textfield? I don't have the Visual Studio dev environment in front of me or I would test it out and make sure I am using the right properties here.

Hey, it compiles.
Go to Top of Page

Brittney10
Posting Yak Master

154 Posts

Posted - 2011-03-15 : 10:39:11
I'm trying to do this client-sided before the form is submitted and i'm staying away from VB and using Javascript. So far my issue has been with capturing the value from my combobox (which comes from a SQL source)
Go to Top of Page

ajthepoolman
Constraint Violating Yak Guru

384 Posts

Posted - 2011-03-15 : 12:06:54
Would something like this do?

$("#TextFieldName").text($("#DropDownName").eq($("#OptionID").attr("selectedIndex")).text());

Hey, it compiles.
Go to Top of Page

Brittney10
Posting Yak Master

154 Posts

Posted - 2011-03-15 : 12:52:29
Still no luck in the ASP.NET environment. I can get the results i'm looking for by hardcoding the dropdownlist and setting it equal to the text field outside of the ASP.NET environment using Javascript. That's why i'm thinking it has something to do with the combobox values not being recognized. I may have a workaround, but would involve using a new form (which i would like to not to do)
Go to Top of Page
   

- Advertisement -