Forum Moderators: open
<script language="JavaScript">
function order(item,desc,cost)
{
var sOrder = "https://www.paypal.com/cart/add=1&business=Myidnumber&item_name=" + desc + "&item_number=" + item + "&amount=" + cost + "";
window.open(sOrder,'cartwin','width=600,height=400,scrollbars,location,resizable,status');
}
</script>
<a class="red" href="javascript:order(item#,item description,item price">Buy now!</a>
Could someone tell me what I'm doing wrong here? I've been cramming CSS and forgot some of the javascript I had learned. Thanks.
Your best bet is to put the site in Netscape, click on the link and then type:
javascript:
in the address bar. This will show you all the errors in JavaScript and the line they appear on. Then post back on here and I will see if I can help any further. Or you may be able to solve it from the description it gives you.
<a class="red" href="javascript:order('item','item description','item price')">Buy now!</a>
Note: had to leave a space after the colon 'cause I was triggering a "shocked" smilie!
Tedster's edit: You can turn off smilies as needed - checkbox is two up from the submit button
[edited by: tedster at 12:12 am (utc) on Aug. 3, 2002]
Is there really a line break in the stuff going into sOrder?
The easy rule is: except in a few specific cases (e.g. in for statements and literal strings) a semicolon will always end a statement.
Since JavaScript is intended to be delivered over a network, a line-break will also terminate a statement only if the code to the left of the line break is a complete statement. This means that the following code is one statement:
var x = a +
b;
...because var x=a+ is not a complete statement. The following, however, is two statements, and the second one gives an error:
var x = a
+ b;
This is JavaScript trying to give you a compromise between readability and efficiency. Sometimes the two considerations come into conflict.