Link to home
Create AccountLog in
Avatar of solution1368
solution1368

asked on

asp.net drop down

i have a asp.net dropdown with value 1 to 5 so we have five row.
When the value is selected, I want to show a pair of city/state
how can I do that in c#/asp.net without post back and without button

and how can i capture the data?
Avatar of leakim971
leakim971
Flag of Guadeloupe image

<script type="text/javascript">
var pairs = [
  ["city1", "state1"],
  ["city2", "state2"],
  ["city3", "state3"],
  ["city4", "state4"],
  ["city5", "state5"]
];

$(document).ready(function() {
   $("#DROPDOWN_ID_ATTRIBUTE_VALUE").change(function() {
       var row_selected = $(this).prop("selectedIndex");
       alert(     pairs[  row_selected   ][0]     );
       alert(     pairs[  row_selected   ][1]     );
   });
})
</script>

Open in new window

Avatar of solution1368
solution1368

ASKER

actually, the way it should be captured in saving city state into the database (SQL),
can you show me how to do  that in codes behind (c#)?
no...that does not help very much. thanks
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account