Lucent Posted August 21, 2009 Share Posted August 21, 2009 Hiya, This is my first time to post here so please forgive me if i've done it a bit wrong, or put it in the wrong section. But as my code start in javascript and thr trouble could be there, I've put it here... but of course the trouble could be in just my php. to sum up what i'm trying to do is adjust the number of (fixed size) columns to display on the page depending on the users resolution (hence the javascript). Here are the snippets of code that are relevant, there is too much code to post the whole lot in the <head> <script type="text/javascript"> var Width = screen.availWidth </script> then to pass this java variable to php i'm using a form (best way i could find) this is only done the first time the page is visited (during login) <input type="hidden" name="width" value="<script>document.write(Width);</script>" /> then set to a session variable with if(isset($_POST['width'])) $_SESSION['width'] = $_POST['width']; $maxcellcount1 = $_SESSION['width']; echo $maxcellcount; echo gettype($maxcellcount1); this outputs 1024 (well for me at the moment) & string (I know it's not the best method to use to find the type, but i had to know) I figure string is good here but i try some maths $maxcellcount1a = $maxcellcount1/250; echo $maxcellcount1a; and this gives 0 so trying settype.. settype($maxcellcount1, float); $maxcellcount1a = $maxcellcount1/250; echo $maxcellcount1a; this also gives 0 i'm going to stop with the code there as anything else doesn't work as this is clearly a stop point, but i'm not sure why this doesn't work. I've tried a few different ways of fiddlign the code, I have also tried to aplied the maths that i want to do to the value in the original javascript var StatusCells = Math.floor(Width/250); and following through an identical process (apart from the last bit of maths i get the same results as far a it's a string though it is a four (as it should be) but when used in an if statment against a counter it well doesn't work... i can give the code for that bit too, but this post is too long already. If anyone can help, I'd really appriciate it as I just can't figure out what is wrong! 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.