I like this answer using jQuery:
$('#seconddiv').live('focus',function(){ $('#firstdiv').attr('disabled', true); });
I have a search panel that gives the search results each time a key is pressed, if it does not return any results, then the user is presented with a form to ask for help. But if they fill out the "request form", then enter the search line again, and it will delete everything that they entered in the request form. Therefore, to solve this problem, I gave all the input in the form of a request id "second div" and a search field id = "firstdiv". Now, if they click or go to one of the input fields of the request form, it will turn off in the search bar so that their data will never be written.
I will also add a button that will turn on the search form again if they change their mind.
And for beginners - I put the code at the beginning of the document as follows:
<html> <head> <script type="text/javascript"> $('#seconddiv').live('focus',function(){ $('#firstdiv').attr('disabled', true); }); </script> </head> <body> ....
John
source share