hi Guys in fallowing code we have the javascript function change(). in change we are getting image src attribute. but after comapring the image we are repacing green image with red image but the change is applicable until completion of function. it is not appicable for the image src in html code. please provide some response. urgent <?php session_start(); if(isset($_SESSION['userid'])) //{ ?> <script type="text/javascript" src="alerts.js"></script> <script language="javascript"> function change() { var image; alert("inside image"); document.getElementById("swa").src="/images/button_red_off_bg2.jpg"; //alert( document.getElementById("swa").src); image =document.getElementById("swa").src; alert("img"+image); if (image == "http://localhost:84/images/button_green_on_bg1.jpg"){ alert("inside if"); document.getElementById("swa").src = "/images/button_red_off_bg2.jpg"; alert("redbutton assigned "); } else{ document.getElementById("swa").src = "/images/button_red_off_bg2"; } return image; } image0 =new Image(); image1 =new Image(); /* var button1_up = new Image(); button1_up.src = "/images/button_green_on_bg1.jpg"; var button1_over = new Image(); button1_over.src = "/images/button_red_off_bg2.jpg";*/ image0.src = "/images/button_green_on_bg1.jpg"; image1.src = "/images/button_red_off_bg2.jpg"; function changeOff() { alert("inside Off"); // document.getElementById("offbutton").style.visibility="visible"; // document.getElementById("onbutton").style.visibility="hidden"; } function changeOn() { alert("inside On"); document.getElementById("onbutton").style.visibility="visible"; document.getElementById("offbutton").style.visibility="hidden"; } function values() { alert("got"); if (document.login1.keyword.value == "") { alert("Keyword field cannot be empty"); return false; } window.open("alertdislay.php?text="+document.login1.keyword.value, "mywindow","width=400","height=300"); } </script> <form name="login1" method="post" action=""> <table width="100%" border="0"> <tr> <td height="30" colspan="3"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td> <div align="left"></div> <div align="left"><font color="#CC9900"><strong><font size="3" face="Verdana, Arial, Helvetica, sans-serif">Insert Keywords</font></strong></font></div></td> </tr> </table></td> </tr> <tr > <td width="96" height="39"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Keywords :</font></td> <td width="17" ><strong>:</strong></td> <td width="258" > <input name="keyword" type="text" id="username" size="32"> </td> </tr> <tr> <td> </td> <td> </td> <td> <input type="submit" name="Submit" value="Click Here !" onclick="return values()"> </td> </tr> </table> <table> <tr><td>ON/OFF </td></tr> <tr><td><input type="submit" name="Submit" value="ON" onclick="return values()"> </td></tr></table> <td> <div id="onbutton" > <input id="swa" type="image" name="sort1" src="images/button_green_on_bg1.jpg" onclick="return change()" /> </div> </td> </form> <?php }else {echo '<script>window.location="login.php";</script>'; }?>