Skip to main content

Posts

Showing posts from 2011

Dropdown Reset Javascript

To reset dropdown/ or selectbox, we can simply fire this javascript code on any dom event document.getElementById("id_of_selectbox").selectedIndex = -1; The selectedIndex method of javascript will reset the index of the selected dropbox. Another and better option is to create a simple function say resetDropbox and call it where-ever you want in your page. function(id_of_dropbox){ document.getElementById(id_of_dropbox).selectedIndex = -1; } Sometime we face problems, when press back button in browser and we get some value pre-selected in dropbox. We can use binding reset scripts on jQuery's Dom Ready , that will put dropbox of the form in its normal(unselected state).

File Write in PHP:

  Different modes of file to operated on a file, you have to open a file with one of these modes. Mode Description 'r' Open for reading only; place the file pointer at the beginning of the file. 'r+' Open for reading and writing; place the file pointer at the beginning of the file. 'w' Open for writing only; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it. 'w+' Open for reading and writing; place the file pointer at the beginning of the file and truncate the file to zero

Selected value/ selected index from dropbox javascript

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script> function haha() { //var e = document.getElementById("select"); var strUser = document.getElementById("select").options[document.getElementById("select").selectedIndex].text; // If you would like to select value then use "value" in place of  "text" alert(strUser); } </script> </head> <body> <select name="select" id="select" onchange="haha();"> <option value="1">a1</option> <option value="2">a2</option> <option value="3">a3</option