javascript - Command Buttons Not Responding to JS functions -
i close finishing program unable past 1 last hurdle. want simple code execute when command buttons pressed. when submit order button pressed following code should run check form completed.
function validateform() { if ($("tax").value = 0) { alert ("you have not selected order"); } if ($("shipcost").value = 0) { alert("you must select method of shipping"); } }
and when reset button pressed following code should run.
function initform() { $('date').value = todaytxt(); $('qty1').focus(); }
unfortunately buttons not executing code trying execute through following set of functions.
window.onload = function () { initform(); todaytxt(); productcosts(); shipexpense(); $('shipping').onchange = calcshipping; calcshipping(); $("submit order").onclick = validateform(); $("reset").onclick = initform(); }
i have created fiddle can see full program: http://jsfiddle.net/khfq2/ appreciated.
you're doing way wrong.
with if statements, use == instead of =.
= in = b means assign value of b == in == b means equals b
read .ready , use instead of window.onload, it's quite bad choice when comes binding, ie.
$( document ).ready(function() { //taken api.jquery.com/ready/ });
if you're using jquery, use # when refering id objects, ie.
$('#tax').val();
on no account should use spaces when giving object unique name or class!
pay attention letters. had ".clisk()" instead of "click()".
check out , provide fixed code.
Comments
Post a Comment