Category: JavaScript

JavaScript img src changer based on hover and unhover

Sorry the demo doesn’t work, if the images existed it would. Use two files ../icondatalink.png and ../iconhoverdatalink.png This is a dynamic image src changer based on hover and unhover. Here is a quick example. <html> <img id=”my-img” src=”../icondatalink.png” onmouseover=”hover(this);” onmouseout=”unhover(this);” /> </html> <script> function hover(element) { var path = element.getAttribute(“src”); var ext = “hover”; var

JavaScript that changes Text box to blank when clicked

Here is a quick example. <html> <input type=”text” id=”UserName” name=”UserName” value=”UserName” onclick=”usernametoblank_clickHandler();”> </html> <script> function usernametoblank_clickHandler() { var val = document.getElementById(“UserName”).value; if (val ==  “UserName”) { document.getElementById(“UserName”).value = “”; } } </script> Please follow and like us:

JavaScript comma delimited input check boxes

Here is a quick example. <html> <input type=”checkbox” onclick=”checkbox_clickHandler(1);”> <input type=”checkbox” onclick=”checkbox_clickHandler(2);”> <input type=”checkbox” onclick=”checkbox_clickHandler(3);”> <input type=”checkbox” onclick=”checkbox_clickHandler(4);”> <input type=”checkbox” onclick=”checkbox_clickHandler(5);”> <input type=”checkbox” onclick=”checkbox_clickHandler(6);”> <input type=”checkbox” onclick=”checkbox_clickHandler(7);”> <input type=”checkbox” onclick=”checkbox_clickHandler(8);”> <input type=”checkbox” onclick=”checkbox_clickHandler(9);”><br> <input type=”text” id=”AccessList”> </html> <script> function checkbox_clickHandler(SiteID) { var str = document.getElementById(“AccessList”).value; var res = str.split(“,”); var x = 0 ;