Link to home
Start Free TrialLog in
Avatar of dorarishome
dorarishome

asked on

JQuery Error and run twice

I have this code:
<script type="text/javascript">
    var names_count = 0;
    var c_count = 0;
    var blocked_seats = 0;
    names_count = 0;
    c_count = 0;
    blocked_seats = 0;



    $(function () {


        $('input#SaveBTN.link').click(function (e) {

			

            e.preventDefault();
			alert("HERE");
            $('.Ctitle').each(function () {
                if ($(this).val() != "Infant") {
                    c_count = c_count + 1;
                    //				

                }


            });
            //alert('namecount '+c_count);


            names_count = c_count + 1;
            blocked_seats = parseInt($('.seats').val());
            //alert(blocked_seats);
            $('.seats').val(blocked_seats - names_count);
            // $("#New_booking_form").submit();
            //alert(names_count);
            names_count = 0;
            c_count = 0;
            blocked_seats = 0;
        });




    });
    names_count = 0;
    c_count = 0;
    blocked_seats = 0;
</script>

Open in new window

I don't know whats wrong!
Avatar of dorarishome
dorarishome

ASKER

.Ctitle is dynamically added to the DOM in the flay.
Avatar of Rainer Jeschor
Hi,
could you please provide either a link to your site or add the html?
What error do you get?
It is impossible to debug this without the related HTML source.
Thanks.

KR
Rainer
ASKER CERTIFIED SOLUTION
Avatar of Alexandre Simões
Alexandre Simões
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial