subzerostudio Posted November 10, 2006 Share Posted November 10, 2006 Hia have a page on my site that is passed the following in the URL 'products_id=n' - where n is a numberI use $_GET['products_id'] to get the id, and of course it works.However when I try and use this in some javascript in the head of my code, it doesn't work - it always interprets $_GET['products_id'] as 28 - even if the products_id passed is 29 or 30The javascript code can be seen in the head of my document (see the link below) (for some reason I can't post it here - whenever i try it redirects me to a 'the connection with the server has been reset' page.. not sure what that is all about??The relevant line is:[code]window.location.href = 'product_info.php?products_id=<?php echo $_GET['products_id']; ?>&colour=' + this.options[this.selectedIndex].value;[/code]So basically what is happening is that even if products_id=30; that line will be interpreted as:[code]window.location.href = 'product_info.php?products_id=28&colour={some colour value}[/code]Why is this happening??You can view the site at [url=http://www.scooter.co.uk]http://www.scooter.co.uk[/url]. And the product_info.php page can be seen by clicking any of the bikes (the site has a url rewrite function on it so it won't display as product_info.php). The problem means that if you select either of the 50cc scooters, and change the colour drop down - the bike will change to 125cc (as this has product id 28!!)Hope I explained myself ok ::)Mike Quote Link to comment Share on other sites More sharing options...
haaglin Posted November 10, 2006 Share Posted November 10, 2006 Not sure about your problem. but you have a hidden field with the correct value:<input type="hidden" name="products_id" value="30">but the value in the javascript has value 28. how do you put the value in the hidden field? Use the same way to put the value in the javascript. or you can give the hidden field an id, an call it by document.getElementById('products_id').value.var id = document.getElementById('products_id').value;window.location.href = 'product_info.php?products_id=' + id + '&colour=' + this.options[this.selectedIndex].value; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.