kash101
kash101

Reputation: 269

Change php property based on browser width

Okay, so i have searched for hours to no avail (most likely because i am not phrasing the question correctly).

Anyway, i would like to change the "list" property of the following script to "big" depending on the size of the client window.

SCRIPT

   <div id="calWrap" class="comType">  
   ?php 

   $calendar_type='list'; //Possible value: mini, big, list    
   include("3c-events/calendar.php"); 

   ?
   </div> 

Any help would be greatly appreciated, i have come across a few posts with scripts i thought would do the trick; however, either through poor implementation or some other reason they failed.

Thanks in advance….

Upvotes: 0

Views: 233

Answers (1)

David Aguirre
David Aguirre

Reputation: 1410

I would suggest getting the size of the viewport with javascript and then sending them to the php on load. Then write some code to check the size and set "calender_type" accordingly.

var viewportWidth = $(window).width();
var viewportHeight = $(window).height();

send the code to the php page with ajax

$.ajax({url: "page.php", type: "post", data: {"size": size}})

you would then return the calender at its proper size. and place it into a designated container.

.done(function(html) {
    $('#someContainer').html(html);
 }(;

Upvotes: 1

Related Questions