cyber_ghost Posted November 23, 2007 Share Posted November 23, 2007 is there a way that i can enabled back the check box after disabling it.? code: // javascript function check_me(num) { if(num==1) // when mouseover document.form1.check_box.disabled=true; if(num==2) // when mouseout document.form1.check_box.disabled=false; } I already try in textbox field.. and it work correct.... how about checkbox? Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted November 23, 2007 Share Posted November 23, 2007 yes, you do it the same way Quote Link to comment Share on other sites More sharing options...
cyber_ghost Posted November 23, 2007 Author Share Posted November 23, 2007 i try it .. but... in always good when mouseover is activated but the checkbox didnot return to enabled when mouseout is activated... Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted November 23, 2007 Share Posted November 23, 2007 I am having trouble trying to figure out what your trying to do. I need you to describe what your trying to do a little bit better; for me to understand what your wanting. Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted November 23, 2007 Share Posted November 23, 2007 are you wanting something like this? <script language="javascript"> function go(direct) { if (direct == "1") { document.form1.check_box.disabled=true; } else if (direct == "2") { document.form1.check_box.disabled=false; } } </script> <form name="form1"> <input type="text" name="num" onmouseover="go(this.value)" onmouseout="go(this.value)" onblur="go(this.value)"> <br><br> <input type="checkbox" name="check_box" disabled> OK </form> if your going to do it like this; if I were you, I would go with the onkeyup event, instead of the onmouse events - but that is totally up to you. Quote Link to comment Share on other sites More sharing options...
cyber_ghost Posted November 23, 2007 Author Share Posted November 23, 2007 sorry for this... my point of view is that.. once a user put the mouse cursor above the checkbox. the checkbox itself turn to disabled. and once the user remove its cursor above the check box... the check turn to enabled again.. here is the code: <!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=iso-8859-1" /> <title>Untitled Document</title> <script language="javascript"> function go(direct) { if (direct == "1") { document.form1.check_box.disabled=true; } else if (direct == "2") { document.form1.check_box.disabled=false; } } </script> </head> <body> <form name="form1"> <label> <input type="checkbox" name="check_box" value="checkbox" onmouseout="go('2')" onmouseover="go('1')" /> move your mouse here</label> </form> </body> </html> Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted November 23, 2007 Share Posted November 23, 2007 well, once you disable the checkbox itself; DOM events, that have to be associated with the checkbox to fire javascript, seem not to work. I have never done it like this before; I guess I would have done the opposite of what your wanting to do, so I guess that is why I never had that issue to come up before. I created a worked around; but it in itself is not 100% guaranteed to accomplish what your wanting to do everytime. The code below that I created; is a quick fix to a possibly un-fixable dilemma, for what you are wanting to do. Here It Is: <!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=iso-8859-1" /> <title>Untitled Document</title> <script language="javascript"> function go(direct) { if (direct == "1") { document.form1.check_box.disabled=true; } else if (direct == "2") { document.form1.check_box.disabled=false; } } function preventPreCheck() { document.form1.check_box.checked=false; } </script> </head> <body> <form name="form1"> <label> <span onmouseout="go('2')" style="padding:5px 4px 5px 5px"> <input type="checkbox" name="check_box" value="checkbox" onmouseover="go('1')"/ onclick="preventPreCheck()" tabindex="-1"> </span> move your mouse here</label> </form> </body> </html> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.