<!DOCTYPE html> <html> <head> <script> function selectedValue() { var index = document.getElementById("myValue").selectedIndex; var value = document.getElementById("myValue").options[index].text; alert(value); } </script> </head> <body> <form> Select your favorite Subject: <select id="myValue"> <option>PHP</option> <option>HTML</option> <option>JQuery</option> <option>Javascript</option> </select> </form> <button type="button" onclick="selectedValue()">Selected Value</button> </body> </html>
Wednesday, July 17, 2013
Get selected value of dropdownlist
Thursday, July 4, 2013
convert stdClass Object to Array in php
<?php /** * Convert an stdClass object to an array * * @param stdClass object $varObj The object to convert * @reeturn array * */ function convertObjectToArray($varObj) { if (!is_object($varObj) && !is_array($varObj)) { return $object; } if (is_object($varObj)) { $varObj = get_object_vars($varObj); } return array_map('objectToArray', $varObj); } /** convert the object to array **/ $resultArray = convertObjectToArray( $obj ); /** Display the result array **/ print_r( $resultArray ); ?>
Subscribe to:
Posts (Atom)