Reputation: 902
Is it possible (I'm sure it is!) to have a system whereby if you alter the first field, the value in there affects the second field? For example:
Position [ ] Points [ ]
Position [ ] Points [ ]
Position [ ] Points [ ]
You have 10 or so of these fields and each relate to each other. If you enter 1 in to position, the points field should pre-populate with 20 points, if you enter 2 then it pre-populates with the related value, then to relate this to all of the rows?
Upvotes: 0
Views: 33
Reputation: 830
Maybe this will get you moving in the right direction:
$('#position1').change(function() {
if($(this).val() == '1') {
$('#points1').val('20');
}
});
the logic can just get more complex if you want to relate more fields to the value of that one. Hopefully this helps.
Here's a simple example
Upvotes: 1
Reputation: 286
Here is a JS Fiddle, I'm using the change event in jquery on the first input to run an if statement to place a value in the second input.
$('document').ready(function(){
$('#position').change(function(){
if($('#position').val()=="1"){$('#points').val("20");}
});
});
Upvotes: 0