Tuesday, January 29, 2008

Mouse Events in JavaScript

//WRITE THESE FUNCTIONS IN JAVASCRIPT ...

function sname_focus()

{

if( window.document.all.sendmsg.SenderName.style.fontStyle == "italic")

{

window.document.all.sendmsg.SenderName.value = "";

window.document.all.sendmsg.SenderName.style.fontStyle = "normal";

}

}

function sname_blur()

{

if( window.document.all.sendmsg.SenderName.value == "")

{

window.document.all.sendmsg.SenderName.value = "Name of Contact";

window.document.all.sendmsg.SenderName.style.fontStyle = "italic";

}

}

function scompany_focus()

{

if( window.document.all.sendmsg.SenderCompany.style.fontStyle == "italic")

{

window.document.all.sendmsg.SenderCompany.value = "";

window.document.all.sendmsg.SenderCompany.style.fontStyle = "normal";

}

}

function scompany_blur()

{

if( window.document.all.sendmsg.SenderCompany.value == "")

{

window.document.all.sendmsg.SenderCompany.value = "Company Name";

window.document.all.sendmsg.SenderCompany.style.fontStyle = "italic";

}

}

function semail_focus()

{

if( window.document.all.sendmsg.SenderEmail.style.fontStyle == "italic")

{

window.document.all.sendmsg.SenderEmail.value = "";

window.document.all.sendmsg.SenderEmail.style.fontStyle = "normal";

}

}

function semail_blur()

{

if( window.document.all.sendmsg.SenderEmail.value == "")

{

window.document.all.sendmsg.SenderEmail.value = "Email Address";

window.document.all.sendmsg.SenderEmail.style.fontStyle = "italic";

}

}

function sphone_focus()

{

if( window.document.all.sendmsg.SenderPhone.style.fontStyle == "italic")

{

window.document.all.sendmsg.SenderPhone.value = "";

window.document.all.sendmsg.SenderPhone.style.fontStyle = "normal";

}

}

function sphone_blur()

{

if( window.document.all.sendmsg.SenderPhone.value == "")

{

window.document.all.sendmsg.SenderPhone.value = "Phone Number";

window.document.all.sendmsg.SenderPhone.style.fontStyle = "italic";

}

}

function smessage_focus()

{

if( window.document.all.sendmsg.SenderMessage.style.fontStyle == "italic")

{

window.document.all.sendmsg.SenderMessage.value = "";

window.document.all.sendmsg.SenderMessage.style.fontStyle = "normal";

}

}

function smessage_blur()

{

if( window.document.all.sendmsg.SenderMessage.value == "")

{

window.document.all.sendmsg.SenderMessage.value = "Message to Send";

window.document.all.sendmsg.SenderMessage.style.fontStyle = "italic";

}

}

function setboxstyles()

{

window.document.all.sendmsg.SenderName.style.fontStyle = "italic";

window.document.all.sendmsg.SenderCompany.style.fontStyle = "italic";

window.document.all.sendmsg.SenderEmail.style.fontStyle = "italic";

window.document.all.sendmsg.SenderPhone.style.fontStyle = "italic";

window.document.all.sendmsg.SenderMessage.style.fontStyle = "italic";

}


========================================================
//If you want to toggle the textbox values, if the mouse is clickes in it ...

input name="SenderName" type="text" value="Name of Contact" id="SenderName" onFocus="sname_focus()" onBlur="sname_blur()" class=contactsendmsg style="font-style:italic" />

// If you want to make a mouse-over events on buttons, etc ...

td width=90 valign=middle align=center style="cursor:pointer" onclick="window.location=('aboutus.htm')" id=aboutdiv class=mainmenutd onmouseover="changelayer_color('aboutdiv','maincolorover');" onmouseout="changelayer_color('aboutdiv','maincolorout');"><font class=mainmenutext>About Usfont>td>


-
ShriKrishna Bhardwaj , With ASP.Net, SQL Server, Javascript

No comments: