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.

  1. with if statements, use == instead of =.

    = in = b means assign value of b  == in == b means equals b 
  2. read .ready , use instead of window.onload, it's quite bad choice when comes binding, ie.

    $( document ).ready(function() {      //taken api.jquery.com/ready/ }); 
  3. if you're using jquery, use # when refering id objects, ie.

    $('#tax').val(); 
  4. on no account should use spaces when giving object unique name or class!

  5. pay attention letters. had ".clisk()" instead of "click()".

check out , provide fixed code.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -