Jump to content

Can't implement jQuery in product.tpl


Recommended Posts

I'm trying with this at product.tpl:

{literal}
<script type="text/javascript" src="{$js_dir}jquery-2.0.2.min.js">
<!--
$(function(){

    var mecanismoMedida = ['100','200',];
    var mecanismoPrecio = ['50','80'];

    $("input").change(function(){update()}).keyup(function(){update()});
							
});
							
function update()
{
    var p = 0;
    for(var i = 0; i < $(".calc").val(); i++)
    {
        if($($(".calc")[i]).prop("checked") == true)
        {
            p += parseInt($($(".calc")[i]).val());
        }
    }
								
    p = parseInt(p);
								
    p += parseInt(val2($("#ancho")));
    p += parseInt(val2($("#alto")));
    p += parseInt(val2($("#cantidad")));

    p = parseInt(p);

    $("#price").html(p);
}

function val2(elm)
{
    if(isNaN(parseInt($(elm).val())))
        return 0;
    else
        return parseInt($(elm).val());
}
// -->
</script>
{/literal}

but isn't working, any ideas about implementing it?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...