Skip to main content

Posts

Showing posts with the label JavaScript

How to deselect all the selection in a select ( combo ) box?

In a HTML page sometimes we may have to deslect all the selection in a select control of html. but as a user we can't do anything. But using Javascript programatically we can achieve this. Here is the sample code in Javascript. function clearSelect( selectObj ){ for (var i = 0; i selectObj .options[i].selected = false; } } note: we need to pass the select object as a parameter to this function. the alternative to this code is function clearSelect( selectObj ){ selectObj.selectedIndex = -1; }

How to call mail client on click of a button using javascript?

There are situations mail id from a text box needs to be populated in the outlook or any other mail client by calling mailto: Here is the one way to do it. <html>     <head>         <script>         function sendMail(){             var mailToId = document.forms[0].mailId.value;             var mailto_link = 'mailto:'+mailToId;             win = window.open(mailto_link,'tempWindow');             if (win && win.open &&!win.closed) win.close();         }         </script>     <head>     <body>         <form name= "mailForm" >         ...

How to remove a option from Select box using javascript?

function deleteOption(id) { listElem = document.getElementById(id); // id of the select box in the html if(listElem.selectedIndex >= 0) listElem.removeChild(listElem.options[listElem.selectedIndex]); //selected item in the select box will be removed if( listElem.options.length == 0 ){ var newOption = document.createElement("OPTION"); newOption.text = "Select One"; // if all the members are removed add default text newOption.value = "Select One"; //default value for the default option text listElem.add(newOption); } }

Drag and Drop table rows with Javascript

There are lot of libraries available to implement drag and drop in Javascript. But this link explains how to do drag and drop on our own and what are all the points to be considered. I found it useful to understand how things are working. http://www.isocra.com/articles/table_dnd.php More Resources: http://www.walterzorn.com/dragdrop/dragdrop_e.htm http://www.webreference.com/programming/javascript/mk/column2/