Log in

View Full Version : inserting script



peteralexander
08-21-2010, 03:36 PM
Hi Guys
I'm trying to insert a script into a sidebar.js file for my website.
The script shows basket quantity and subtotal.
I can insert it into a html page and it works fine but does not work when i insert it into the sidebar.js. I would like the basket on the sidebar rather than on the page itself. You can see how I want it to look here www.pwauk.com/test2.htm (http://www.pwauk.com/test2.htm)

This is the area i wish to insert the code.
[CODE]//
1ST NOTES AREA

if (notes1 == "yes") {
document.write('<fieldset><legend>');

document.write('Your Shopping Basket<br></legend>');

document.write('<div align="center"><img src="shopping_cart_2.gif" width="100" height="80"></div> <br><br> ');
document.write('Basket Qty:<br><br>');
document.write('Subtotal:<br><br>');
document.write('<a href="http://www.romancart.com/cart.asp?storeid=25978">View Basket & Checkout</a>');
document.write('</fieldset>');
document.write('<br><br><br>');
}
[CODE]

And the two lines i want to insert is
[CODE]
<SCRIPT LANGUAGE="JavaScript" SRC="http://www.romancart.com/cartinfo.asp?storeid=25978&type=1"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="http://www.romancart.com/cartinfo.asp?storeid=25978&type=5"></SCRIPT>
[CODE]

Anyone got any ideas?
Thanks
Peter
Sorry, I think I've posted this in the wrong section!

bluewalrus
08-21-2010, 03:55 PM
The code you're trying to insert calls the code it isn't the actually code which is what the js file would want put in


var cText = '0'; document.write(cText);


and


var cText = '£0.00'; document.write(cText);


These seem to conflict and I don't think it will work as you want..

peteralexander
08-21-2010, 04:09 PM
Thanks for your prompt reply.
Are you saying I can't have these two scripts working in the sidebar?

Sorry i'm clearly not up to speed on programming so its all trial and error! more error actually.

If it won't work, I'll scrap the idea.

Regards
Peter

bluewalrus
08-21-2010, 04:17 PM
Your setting cText to 2 different values. I'm not sure which it should be cause I don't see where it is being used. I assume the first is for math functions and the second is for display purposes.

peteralexander
08-21-2010, 04:22 PM
The first line of script is for how many items you put in the basket and the second line is the subtotal of items used in the basket.
The amounts are automatically updated instantly once you add an item to basket and the info is called from the Romancart site.
If you look at the page www.pwauk.com/test2.htm (http://www.pwauk.com/test2.htm) you can see it working on the page across the top and where i want it on the sidebar.

peteralexander
08-21-2010, 09:53 PM
No Worries, got it sorted by another method. Thanks for your help.
Regards
Peter