JavaScript

Show a Certain Div's Contents if a Certain Option is Selected in a Select

A client needed me to show a certain hidden div on the page if a certain option was selected in a dropdown box. Here is the javascript/jquery code I used to show the div when the option was selected. I had multiple items on the page with the same dropdown box so I also needed …

Show a Certain Div's Contents if a Certain Option is Selected in a Select Read More »

Concatenating Strings in PHP and JavaScript

Combining two strings into one string is easy with both PHP and JavaScript. In PHP: $string1 = ‘Hello’; $string2 = ‘World!’; $string3 = $string1.’ ‘.$string2; echo $string3; // prints – Hello World! In JavaScript: string1 = ‘Hello’ string2 = ‘World!’ string3 = string1 + ‘ ‘ + string2 alert(string3) // prints – Hello World! in …

Concatenating Strings in PHP and JavaScript Read More »

How to Pass an Object from PHP to Javascript and Back Again Using JSON

Many times I would like to pass an object from my PHP code to Javascript or from Javascript to PHP. JSON and a couple of PHP and Javascript functions make that easy! JSON is JavaScript Object Notation. Basically, it’s a textual way to represent an object. To demonstrate, I will create a PHP object: <?php …

How to Pass an Object from PHP to Javascript and Back Again Using JSON Read More »

Scroll to Top