Click here to Skip to main content
16,016,489 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a text boxes that is dynamically created i want to compare the value of the textboxes to a textbox that sums the values in the dynamically generated textbexes

What I have tried:

function compareVals() {
var subtotal = 0;
var sum = 0;
$("input[name='subtotal[]']").each(function (index) {


var subtotal = $("input[name='subtotal[]']").eq(index).val();
var totalAmount = $("#sum").val();

if(!isNaN(subtotal && (subtotal)))
{
if(totalAmount > subtotal) {
$("input[name='subtotal[]']").eq(index).addClass('changeShape');
}else {
$("input[name='subtotal[]']").eq(index).removeClass('changeShape');
}
}
});
}
Posted
Updated 23-Jul-17 0:59am

1 solution

What you'd do in JavaScript, once the two boxes are generated.

If you remember to give each one an id, It should be simple enough:
JavaScript
 <script type='text/javascript'>
  var box1 = docuement.getElementById('box1').value;
  var box2 = docuement.getElementById('box2').value;

  if( Appropriate_String_Comparison(box1, box2) == 0) {
    doSomething();
  }
  else
    doSomethingElse();
</script>

This is using simple javaScript. No magic frameworks are needed.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900