jQuery webforms value created by jQuery does

I have these webform controls

<asp:TextBox ID="HoursWorkedMonday" CssClass="data-input rt" ClientIDMode="Static" runat="server" TabIndex="2" />
....
....
....
<asp:TextBox ID="HoursWorkedSaturday" CssClass="data-input rt" ClientIDMode="Static" runat="server" TabIndex="2" />
...
...
 <asp:TextBox ID="TotalRegular" CssClass="data-input" ClientIDMode="Static" runat="server" Enabled="False" /></div>

The hours are for TotalRegular are accumulated with jquery

       

            $(".rt").each(function () {

                $(this).focusout(function () {
                   [b] calculateRegularHoursSum();[/b]
                });
            });

  function [b]calculateRegularHoursSum()[/b] {
            var sum = 0;
            $(".rt").each(function () {

                if (!isNaN(this.value) && this.value.length != 0) {
                    sum += parseFloat(this.value);
                }
            });
            $("#TotalRegular").val(sum)
        }

Open in new window


If I populate the controls from code behind in c#  when I run this code in jQuery



                    var reghours = $("#TotalRegular").val();
                        if (!reghours.trim()) reghours = 0;
                        $("[id$='regularhours']").html(reghours).text();



        <div id="ConfirmPanel" style="display:none">
            <div class="dialog-label">Regular Hours</div>
            <asp:Label ID="regularhours" CssClass="hours-label" runat="server" /><br />
            <div class="dialog-label">Overtime Hours</div>
            <asp:Label ID="overtimehours" CssClass="hours-label" runat="server" /><br /><br />
        </div>

Open in new window



the dialog displays nothing.  Only if I go in one of those fields and do a focusout() does the control have values
Charles BaldoSoftware DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Alexandre SimõesManager / Solutions ArchitectCommented:
That's a bit of a mess of code formatting there, but as far as I understood, you're only calling calculateRegularHoursSum onfocus out, so it makes sense that the calculation only gets updated if you leave one of the boxes.

Probably what you want is to add this to your code:
$(document).ready(function(){
	calculateRegularHoursSum();
});

Open in new window

This triggers the calcullation when the page loads.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Charles BaldoSoftware DeveloperAuthor Commented:
Thank you
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.