Flash Games
 FAQ   Search   Memberlist   Usergroups   Register  Profile   Log in to check your private messages   Log in 


Tricky(FFonly):Changing button status on cut/paste operation



 

Post new topic   Reply to topic  
   DEVPPL Forum Index -> JavaScript Forum
View previous topic :: View next topic  
Author Message
rgo



Joined: 22 May 2008
Posts: 2

PostPosted: Thu May 22, 2008 3:49 pm    Post subject: Tricky(FFonly):Changing button status on cut/paste operation Reply with quote

I have a simple html page with a textbox and a button. I need to make button disabled/enabled on performing cut/paste operation respectively using mouse.

I could easily make it work on IE & Safari with using "mouseout" event. But this event has a different behavior in FF..here is how,

In IE/Safari, the ‘mouseout’ event doesn’t fires before the you perform any action (cut/paste) on context menu (right click pouup menu), so when mouseout event fires, we get the new value in textbox to change status of ‘Add” button.

But in Firefox, this event fires immediately after you move mouse out of textbox to perform any action (cut/paste) on context menu. So when mouseout event fires, we still have the old value in textbox and hence button remains in same state.

How can we handle this to change button status (disabled/enabled) immediately after we cut/paste text from textbox using mouse ?

This can be fixed up to an extend using timer i.e. adding a delay in invoking action method resultClicked() so that we get the new value in textbox. But that is not an expected soln.

Here is the html source I have,

<HTML>
<HEAD>
<script type="text/javascript">
function resultClicked(event){
var mobileNo= document.getElementById('text1').value;
if(mobileNo==""){
document.forms[0].AddButton.disabled = true;
} else{
document.forms[0].AddButton.disabled = false;
}
}
</script>
<FORM>
Mobile <input name="text1" type="text" value ="1111111111" id="text1" onkeyup="javascript:resultClicked(event);" onmouseout="javascript:resultClicked(event);" />
<input type="button" value="Add" name="AddButton">
</FORM>
</BODY>
</HTML>
Back to top
View user's profile Send private message
rangana
500+ Club


Joined: 27 Feb 2008
Posts: 718
Location: Cebu City Philippines

PostPosted: Fri May 23, 2008 2:29 am    Post subject: Re: Tricky(FFonly):Changing button status on cut/paste operation Reply with quote

There are times, that the "structure" of your markups do comes an issue Wink

Have you tried closing your head section first and opening the body section then:
Code:

<HTML>
<HEAD>
<script type="text/javascript">
function resultClicked(event){
var mobileNo= document.getElementById('text1').value;
if(mobileNo==""){
document.forms[0].AddButton.disabled = true;
} else{
document.forms[0].AddButton.disabled = false;
}
}
</script>
</head>
<body>
<FORM>
Mobile <input name="text1" type="text" value ="1111111111" id="text1" onkeyup="javascript:resultClicked(event);" onmouseout="javascript:resultClicked(event);" />
<input type="button" value="Add" name="AddButton">
</FORM>
</BODY>
</HTML>


I'm unaware if this is just a test page, but always remember that a DTD is important too Smile

Hope that helps.
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
rgo



Joined: 22 May 2008
Posts: 2

PostPosted: Mon May 26, 2008 7:52 am    Post subject: Re: Tricky(FFonly):Changing button status on cut/paste operation Reply with quote

Thanks Rangana for your response ..but that doesn't helps. It is the problem with the behavior of 'mouseout' event in FF and I am looking for a work around for that.
Back to top
View user's profile Send private message
rangana
500+ Club


Joined: 27 Feb 2008
Posts: 718
Location: Cebu City Philippines

PostPosted: Mon May 26, 2008 8:49 am    Post subject: Re: Tricky(FFonly):Changing button status on cut/paste operation Reply with quote

I'm not seeing any oddity rgo, tested on both FF and IE, which seemed working (for me).
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    DEVPPL Forum Index -> JavaScript Forum All times are GMT + 1 Hour
Page 1 of 1

 
 
Welcome to DEVPPL.com
You are not logged in, which means that you can't post in the forums.
Click here to Register

If you are a current member here on DEVPPL, please login below:

User: Pass:
Log me on automatically each visit:

 


Powered by phpBB © 2001, 2005 phpBB Group - Modified by DEVPPL

Flash Games - Sitemap