Month: March 2014

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 ;

Python Count every char in a text file

letters = [‘a’,’b’,’c’,’d’,’e’,’f’,’g’,’h’,’i’,’j’,’k’,’l’,’m’,’n’,’o’,’p’,’q’,’r’,’s’,’t’,’u’,’v’,’w’,’x’,’y’,’z’,’A’,’B’,’C’,’D’,’E’,’F’,’G’,’H’,’I’,’J’,’K’,’L’,’M’,’N’,’O’,’P’,’Q’,’R’,’S’,’T’,’U’,’V’,’W’,’X’,’Y’,’Z’] counter = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] i = 0 print “Started” with open(‘alice.txt’) as f: while True: c = if not c: print “Done” break for letter in letters: if c == letter: counter[i] = counter[i] + 1 i = 0 break i = i + 1 if i == 52: i = 0