Tuesday, February 26, 2008

HTML Button related Javascript Functions

1.How to create an IMAGE button through Javascript
Function Arguments
  1. srcImg:-the Default Image url
  2. mouseOverImg :- the mouse over Image url
function createIMGButton(srcImg,mouseOverImg){
var but=document.createElement("IMG");
but.onmouseover=new function(){but.src=mouseOverImg;}
return but;

2.HTML Button Mouse Listener.
Function Arguments
  1. but:-The HTML button Object
  2. mouseOverImg :- the mouse over Image url
  3. mouseOutImg:- the mouse out Image url

function buttonMouseListener(but,mouseOverImg,mouseOutImg){
but.onmouseover = function(){but.src=mouseOverImg;}
but.onmouseout = function(){but.src=mouseOutImg;}

3.Create HTML CheckBox
Function Arguments
  1. The id of the checkBox.
function createChkBox(id){
var checkBox = document.createElement("input");
checkBox.type = "checkbox"; // set type
checkBox.id = id;
return checkBox;

No comments: