Announcement

Collapse
No announcement yet.

Javascript Error Relating to Stock Display Scripts

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Javascript Error Relating to Stock Display Scripts

    I'm in the process of changing a few of my shop sections from multi product page layouts to single product pages but on the new single product pages I am getting an error that says "A Javascript error has been found on the page ('Syntax error')."

    I've managed to trace this back to the code in my "Javascript Product Stock Query" layout which is as follows:-
    Code:
    	<actinic:block if="%3cactinic%3avariable%20name%3d%22RealTimeStockEnabled%22%20%2f%3e%20%26%26%20%3cactinic%3avariable%20name%3d%22DisplayRealStockLevel%22%20%2f%3e" >
    		<script language="javascript" type="text/javascript">
    		var nAssocProdRefSID = 	'<actinic:block type="ComponentList" ><actinic:variable name="ComponentCount" /></actinic:block>' ? <actinic:variable name="SectionID" /> : 0;
    		function displayStock()
    			{
    			var sProdRefs = "";
    			var sStockList = "";
    			<actinic:block if="%3cactinic%3avariable%20name%3d%22IsPreviewMode%22%20%2f%3e" >
    				sProdRefs = "<actinic:variable name="RTSProductsInThisSection" selectable="false" />";
    				sStockList = "<actinic:variable name="RTSStocksInThisSection" selectable="false" />";
    				getProductStock('<actinic:variable name="StockScriptCGIURL" selectable="false" />', sProdRefs, sStockList, '');
    			</actinic:block>
    			<actinic:block if="%3cactinic%3avariable%20name%3d%22IsHostMode%22%20%2f%3e%20%26%26%20%21%3cactinic%3avariable%20name%3d%22IsPreviewMode%22%20%2f%3e" >
    				getProductStock('<actinic:variable name="StockScriptCGIURL" selectable="false" />', '<actinic:variable name="ProductReference" />', sStockList, '<actinic:variable name="ShopID" selectable="false" />');
    			</actinic:block>
    			<actinic:block if="%21%3cactinic%3avariable%20name%3d%22IsHostMode%22%20%2f%3e%20%26%26%20%21%3cactinic%3avariable%20name%3d%22IsPreviewMode%22%20%2f%3e" >
    				getProductStock('<actinic:variable name="StockScriptCGIURL" selectable="false" />', '<actinic:variable name="ProductReference" />', sStockList, '');
    			</actinic:block>
    			}
    
    		AttachEvent(window, "load", displayStock);
    		</script>
    	</actinic:block>
    It seems to be the 3rd line down that causes the error, the one that reads:-
    Code:
    var nAssocProdRefSID = 	'<actinic:block type="ComponentList" ><actinic:variable name="ComponentCount" /></actinic:block>' ? <actinic:variable name="SectionID" /> : 0;
    as when I remove this line I do not get an error.

    So my question is, Is my code correct or have I somehow managed to get this spurious line of code added somewhere along the way?

    If my code is correct does anyone else get this error message, or, if it's incorrect could someone please let me know the correct code.

    Thanks.

    Garry.
    Garry

    www.4AllCards.com

    #2
    I've been playing around with this problem and it is definately the line of code:-
    Code:
    var nAssocProdRefSID = 	'<actinic:block type="ComponentList" ><actinic:variable name="ComponentCount" /></actinic:block>' ? <actinic:variable name="SectionID" /> : 0;
    If I change this to something like:-
    Code:
    var nAssocProdRefSID = 0;
    Then the error goes away. To my mind this line of code must be incorrect as it is trying to set a variable to 5 different things which is why the error goes away when it's changed to just set it to 0. If nAssocProdRefSID should be set to a string value of the 5 items then surely it should be coded differently?

    Does no one else get this error???
    Garry

    www.4AllCards.com

    Comment

    Working...
    X