What i have is working, so I'm just asking if there's a more elegant way to do this. I have:
<form method="post" action="15Action.cfm">
<p><input id="A" name="A1"></p>
<p><input id="B" name="B1"></p>
<p><input id="C" name="C1"></p>
<input name="Submit" type="submit" value="submit">
</form>
If the changes either A or B, then concatenate the two fields together and place them into C. What I have is:
function doit(A,B) {
return A+B;
};
$(function() {
var A = $('#A');
var B = $('#B');
$('#A, #B').change(function() {
$('#C').val(doit(A.val(),B.val()));
});
});
I wonder if I should write
$('#C').val(doit(A,B))
instead, or is it acceptable to pass A.val(), B.val()?