开发者

how does the javascript function call works given in description?

I have a select box whose onChange attribute executes the functions given as:

<select id="shipping_method" name="shipping_method" onChange="javascript:quantity(), price(), Shipping();" style="width: 209px;">
    <option value="">Select Shipping</option>
    <option value="standard">Standard (7 - 12 days from proof)&开发者_JAVA百科lt;/option>
    <option value="expedited">Expedited (5 work days from Proof)</option>
</select>
​


In JavaScript, a comma separates a sequence of expressions. The expressions are evaluated in turn from left to right. This is often used when declaring variables:

var var1, var2 = 12, var3 = true;

And omitting braces from if statements:

if (something == true)
    doSomething(),
    doAnotherThing();
else
    doSomethingElse();

But they can generally be used to separate any expression, providing the expressions that are being seperated don't contain language construct statements like return, if, break, etc.

In the example you supplied, it's more or less the same as

onchange="quantity(); price(); Shipping();"

(note the javascript: label is not required in event handlers and it doesn't do what you probably think it does. Also, to avoid confusion when working with DOM events, try and stick to lowercase event names instead of camelCase.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜