Reputation: 107
I am new to MVC and I have 2 text boxes,On 1 text box I need to type the numbers based on the number it should get the data from a lookup table(where MyAge is the lookup table) based on the number that I enter in one text box
@foreach (var pa in Model[i].MyAgeTable)
{
if (TextboxAge.trim() == pa.Trim())
{
....
}
}
Upvotes: 0
Views: 470
Reputation: 3360
You can use jQuery to do this. For using jQuery you need to add the following in your head:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
and then the following code will do what you want:
<script type="text/javascript" >
$(document).ready(function (){
$("#textBox1").keypress(updateTextBox2());
function updateTextBox2() {
// code to get update another textbox
}
});
</script>
There are different ways of writing the code to get the data from look up table. For instance you can make an ajax request to the server.
Documentation for jQuery.ajax()
Upvotes: 1