jquery / submit button validation

jerrod09 27 Apr, 2016
I am using Joomla C5 in advanced mode and have a form that is just about finished up. I have some very short javascript/jquery code that I tried to add to the onload event via the "load javascript" under Setup which calculates tonnage. The code simply will not work when I add it this way.

However, when I add the js code directly via the Designer/custom code (pure code) and call the javascript library there locally in the code I can get the code to function BUT, then it interferes and renders useless the validation that I setup on certain selectors and the submit button. (I basically did this just to troubleshoot where my problem was)Perhaps it is a load order issue.

So, I can see there is obviously a conflict with the jquery code that I am adding. Something isnt right. I have jQuery Easy setup which is managing the library loads.

The jquery code I am inserting works great standalone on a jsfiddle and single html page...and like I said when I force it into a custom code under designer, it works but messes up the form validations etc. I wish it did work as it calculates values realtime and also on page load.

Ive posted the jquery code below followed by a link to a test of the form below - in hopes that there is something glaringly obvious that you might be able to see that is is in a conflict that I have missed that is causing the conflict/trouble.:
$(document).ready(function(){
    update_amounts();
    $('.qty').change(function() {
        update_amounts();
    });
});



function update_amounts()
{
    	
	var sum = 0.0;
    $('#myTable > tbody  > tr').each(function() {

        var qty = $(this).find('.qty').val();
        var price = $(this).find('.price').val();
        var amount = (qty*price/2000)
        sum+=amount
        $(this).find('.amount').text(''+amount);
    });
   
    $('.total').val(sum);
}

This is private content

GreyHead 28 Apr, 2016
Hi jerrod09,

The form is showing as Not Published on the link you posted so I can't check that. But I can see a jQuery error from K2 on the page that would stop your code working.

Bob
jerrod09 28 Apr, 2016
Thank you GreyHead for the quick response.

I actually solved the issue by placing the call for the javascript library (link to the google one) directly in the load javascript for the onload event. I figured that it would grab the library from the already loaded one on the page, but this was critical. Placement seems to be critical in my particular setup. I will look into the K2 issue now that you mentioned it. As soon as the client pays, I will be purchasing chronoforms validation for their site. The component has helped me out a lot, and again, I appreciate the response to my initial question.
This topic is locked and no more replies can be posted.