0

How to call this javascript function in .aspx file in VB.net code. ANy help in this regards would be much appriciable.

$(document).ready(function() {

var numberInput = $('#A_SAtxt, #A_SStxt, #A_RAtxt, #A_CAtxt, #A_OItxt, #A_ICtxt, #A_Otxt');

numberInput.on('change', function() {
    var total = 0;

    numberInput.each(function() {
        if ($(this).val() !== '') {
            total += parseFloat($(this).val());
        }
    });

    $('#A_TAtxt').val(total);
});

});

I have even tried to do the following in the page load event but it doesn't work.

    Dim sb As New System.Text.StringBuilder()
    sb.Append("<script type = 'text/javascript'>")
    sb.Append(" $(document).ready(function() {")
    sb.Append(" var numberInput = $('#A_SAtxt, #A_SStxt, #A_RAtxt, #A_CAtxt,                 

            #A_OItxt, #A_ICtxt, #A_Otxt');")
    sb.Append("  numberInput.on('change', function() {")
    sb.Append(" var total = 0;")
    sb.Append("else{")
    sb.Append(" numberInput.each(function() {")
    sb.Append("  if ($(this).val() !== '') {")
    sb.Append("  total += parseFloat($(this).val());")
    sb.Append(" }")
    sb.Append(" });")
    sb.Append(" $('#A_TAtxt').val(total);")
    sb.Append("  });")
    sb.Append(" });​")

    sb.Append("}};</script>")
    ClientScript.RegisterClientScriptBlock(Me.GetType(), "function", sb.ToString())
1

1 Answer 1

-1

Make sure you have jquery running on your computer. Or import jquery :P

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.