Author: admin

  • Convert Month Numbers to Month Names in PHP

    Here is a lovely bit of code to help you convert months in numbers to proper names! <?php $monthNum = 11; $monthName = date(“F”, mktime(0, 0, 0, $monthNum, 10)); echo $monthName; // Outputs: November ?>

  • Force links to open in a new tab, not a new window

    Yes it is possible with CSS to have links open in new tabs or new windows. I discovered this issue when testing target=”_blank” in IE9/IE10 versus Chrome. <a href=”[yourlink]” target=”_blank” style=”target-new: tab;”>GetPowers</a> Or you could put it in the header as: <html> <head> <style> a { target-new:tab; } </style> </head> <body>  There are some options…

  • Disable resize for textarea tags

    This little bit of css will disable resizing of textarea boxes. textarea { resize:none; }

  • HTML Actions vs Javascript Callbacks

    HTML actions: The action attribute specifies where to send the form-data when a form is submitted. In HTML5, the action attribute is no longer required. We can use javascript to send data on the backend using AJAX. http://www.w3schools.com/tags/att_form_action.asp Callbacks in javascript: In general, a callback function is used once another function you have called finishes.…

  • Reset your form after submit using jQuery

    After you submit a form, you reset it with the following code: $(“form#myform”)[0].reset(); For example on my Magic8Ball website, I created a function to submit the form and reset it immediately, clearing out the input elements. var formData = $(“#form”).serializeArray(); $.ajax({ url : “speaktome.php”, type: “POST”, data : formData, success: function(result) { $(“.youranswer”).hide().html(” + result…

  • SP1sport.com – Exciting new quiz website for sports fans!

  • Change your cursor to waiting or in-progress with jQuery.

    Found this great bit of code on SO. Basically, it changes your cursor to the progress or wait symbol whenever AJAX is started on your page. Nice for forms or submissions by the user. $(‘body’).ajaxStart(function() { $(this).css({‘cursor’:’wait’}) }).ajaxStop(function() { $(this).css({‘cursor’:’default’}) }); By the way here is a great page from w3schools on cursor types!

  • Finding nested items in JSON object or associative array using PHP

    I had this problem recently when I used made a call to Yahoo Finance’s Stock quotes API for my Chinese website about US Stocks. Yahoo’s API returns the stock data in JSON form, but you can choose to handle it as a php object or associative array. First, this post by Michael Nitschinger really helped…

  • Dealing with apostrophes and quotation marks for forms and output with PHP

    I have run into the same annoying problem for a long time and finally found an easy solution. Whenever forms are submitted via PHP (by a user or myself) and apostrophes or quotation marks are added in forms, they are escaped using mysqli_real_escape_string and entered into the database without a hitch. However, when outputting the data…

  • Ultra-easy image rollover solution with jQuery (no plug-ins needed)

    Found a fantastic image rollover solution on StackOverflow recently, with this little piece of jQuery and no other plug-ins needed your rollovers works easily and seamlessly… HTML <img data-other-src=”big-zebra.jpg” src=”small-cat.jpg”> <img data-other-src=”huge-elephant.jpg” src=”white-mouse.jpg”> <img data-other-src=”friendly-bear.jpg” src=”penguin.jpg”> Javascript $(‘img’).on(‘mouseenter mouseleave’, function() { $(this).attr({ src: $(this).attr(‘data-other-src’), ‘data-other-src’: $(this).attr(‘src’) }) });