Skip to main content

Posts

Change value JS, PHP getting old value

I've a silly problem. Depending on a the visibility of a div I want to set a hidden value if($('#crewMember').is(':visible')) { $('#visibility').attr('value', 'hidden') } else { $('#visibility').attr('value', 'visible') } This works. I've checked it via FireBug and I can see that the HTML has changed. But when I try to get this value after form submission I get the original value, not the changed value. echo $_POST['visibility'] //returns default value, not the adjusted valueHow come? How come? EDIT SOme example code <html> <script type="text/javascript"> $(document).ready(function() { $('#div').click(function() { $('#visibility').val('hidden'); $('#value').html('hidden value: ' + $('#visibility').val()); }); $('#value').html('hidden value: ' + $('#visibility').va

change the url in facebook comments code?

on my website I have more than 200 pages and I want to add facebook comments feature to my website. I ran to this problem is that I have to change the code (the url) for each page. I do not want to change the code for every page. If you can see the second piece of code contain Url goes here can I include a method like location.href so that it can use the current url of the page. can I do this ? I do not care if it is php, javascript, or anything ealse. Include the JavaScript SDK on your page once, ideally right after the opening <body> tag. <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=324524777119"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> Place the code for your plugin

PHP passing variable in __construct of a class

ive browsed many articles here but I just can't make this work for the life of me. class Database{ private $host; function __construct( $vhost = ''){ $this->host = $vhost == '' ? db_host : $vhost; } function connect(){ echo "Host: ".$this->host; } } I've omitted some unnecessary code but it's same concept. I get "Fatal error: Using $this when not in object context" when trying to echo. What am I missing here?

Including a file in json_encode()

Thsi does not seem to work: $msg="Your changes have been saved successfully"; $view=include('application/view/admin/cms/_slides-current.php'); $return_array=array('success'=>true, 'msg'=>$msg, 'view'=>$view); echo json_encode($return_array); The array needs to be passed back to a jQuery ajax success callback. Anybody know how it should be done? The include file is simply a HTML template. This HTML template will be inserted on to the page. Is there any way other than using json_encode() to do what I am trying to do? success: function(result){ alert(result.msg); if(result.success == true) { $('#slides').html(result.view); } }

How to read an SVG with a given size using PHP Imagick?

I have the following code: $image = new Imagick(); $image->setBackgroundColor(new ImagickPixel('green')); $image->setSize(20,20); $image->readImageBlob(file_get_contents('./some/path/image.svg')); It loads the SVG just fine but the setSize just gets completely ignored. It renders at 550x100, as per it's definition: <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="550px" height="100px" viewBox="0 0 550 100" enable-background="new 0 0 550 100" xml:space="preserve"> Has anyone got experience in getting SVG files to play nice with setSize ?