Advertisement
manchumahara

Mootools on blur search box and submit

Jul 29th, 2012
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.25 KB | None | 0 0
  1. <script type="text/javascript">
  2. //<![CDATA[
  3.     window.addEvent('domready', function() {
  4.         var value;
  5.  
  6.         // Set the input value if not already set.
  7.         if (!$('mod_finder_q45').getProperty('value')) {
  8.             $('mod_finder_q45').setProperty('value', 'search...');
  9.         }
  10.  
  11.         // Get the current value.
  12.         value = $('mod_finder_q45').getProperty('value');
  13.  
  14.         // If the current value equals the previous value, clear it.
  15.         $('mod_finder_q45').addEvent('focus', function() {
  16.             if (this.getProperty('value') == value) {
  17.                 this.setProperty('value', '');
  18.             }
  19.         });
  20.  
  21.         // If the current value is empty, set the previous value.
  22.         $('mod_finder_q45').addEvent('blur', function() {
  23.             if (!this.getProperty('value')) {
  24.                 this.setProperty('value', value);
  25.             }
  26.         });
  27.  
  28.         $('mod-finder-45').addEvent('submit', function(e){
  29.             e = new Event(e);
  30.             e.stop();
  31.  
  32.             // Disable select boxes with no value selected.
  33.             if ($chk($('mod-finder-45-advanced'))) {
  34.                 $('mod-finder-45-advanced').getElements('select').each(function(s){
  35.                     if (!s.getProperty('value')) {
  36.                         s.setProperty('disabled', 'disabled');
  37.                     }
  38.                 });
  39.             }
  40.  
  41.             $('mod-finder-45').submit();
  42.         });
  43.  
  44.         /*
  45.          * This segment of code sets up the autocompleter.
  46.          */
  47.     });
  48. //]]>
  49. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement