View Full Version : JavaScript/PHP

07-13-2002, 05:18 AM
I currently program my entire web site in PHP. However, recenty I needed to detect the screen size and subtract a certain amount from it, then create a table that wide. BUT, unfortunately it doesn't work.

Can someone please help me on how to detect a user's screen size with PHP?

07-13-2002, 10:55 AM
I think it can't be done using only PHP. As your subject says, you might need JavaScript.

PHP is executed on the server before any information of the user (like screen size) is sent to PHP.

Mzzl, Chris

07-13-2002, 12:09 PM
You should use relative (%) values rather than absolute :

For example : if you want the table to be half the size of the screen do :

<table width="50%">

07-14-2002, 05:53 AM
whilst you can not rely on anyone having javascript .. you can pass the width and height from javascript to PHP...

function have_script(){
<body onload="have_script()">
echo "$_GET[height] :: $_GET[width]";
echo "javascript not available";

so that reloads the page with the $_GET[width] && $_GET[height] variables available to PHP, non-js browsers will just ignore it so you can not depend on the values being available.

11-25-2005, 08:42 PM
How to call to a function in javascript sending a numerical parameter? This parameter will be used in php code inside javascript:

call the javascript function:
<A href='javascript:void(0)' onClick='ShowFAQ(25)'>text</A>

<script type="text/javascript">
function ShowFAQ(faqid){
window.document.labeltitlefaq.innerText='<?php echo($arrayFAQtitle[faqid])?>' ;

Thanks for your support

11-25-2005, 08:43 PM
Forget to say that the previous code does not work.

08-28-2006, 05:07 AM
Hello :( I would like to know how can I save in a php variable the result of a javascript function :confused: Thank you