Find solution

How can I pass global variables into a function?

Here are 14 best answers to ‘How can I pass global variables into a function?’ - the most relevant comments and solutions are submitted by users of Stack Overflow, Quora and Yahoo! Answers.

Best solution

  • How do I pass variables into a JavaScript function?

    Is it possible to pass variables into a js function? See code: function checkStartPrice (){ if ($('#StartingPrice')[0].value.length == 0){ alert("The 'Starting Price' cannot be left empty!"); return false; } else { var BuyItNowPrice = parseFloat($('#BuyItNowPrice').val()); var StartingPrice = parseFloat($('#StartingPrice').val()); var Reserve = parseFloat($('#Reserve').val()); if((BuyItNowPrice <= StartingPrice) && (StartingPrice > 0)){ alert("The 'Buy It Now' price...

    Answer:

    A simple example of passing variables into a function is below. When you declare a function, you can...

    Mark as irrelevant Undo

Other solutions