views:

22

answers:

0

I'm trying have default values for Zend_Dojo_Form_Elements be set to '' when a user clicks into the element. This works fine for a TextBox and partially for a FilteringSelect

The FilteringSelect clears, but it does it when you click on the drop down arrow too, causing the drop down to not work. I'd like to have it clear only when you click on the TextBox portion of the FilteringSelect

// Price
        $Price = new Zend_Dojo_Form_Element_TextBox('Price',array(          
            'required'  => false,                   
            'onclick'   => 'clearElement(this,"Max Price")',    
            'onblur'    => 'resetElement(this,"Max Price")',                                
        ));     
        $Price->setValue('Max Price')

// Baths
        $Baths = new Zend_Dojo_Form_Element_FilteringSelect('Baths',array(
            'required' => false,            
            'multiOptions' => array(
                '0'=>'Baths',
                '1'=>'1',
                '1.5'=>'1.5',
                '2'=>'2',
                '2.5'=>'2.5',
                '3'=>'3',
                '3.5'=>'3.5',
                '4'=>'4',
                '4.5'=>'4.5',
                '5'=>'5',
                '5.5'=>'5.5',
                '6'=>'6',                                       
            ),              
            'onclick'   => 'clearElement(this,"Baths")',    
            'onblur'    => 'resetElement(this,"Baths")',            
        ));
        $Baths->setValue('0')

And the javascript

function clearElement(field, defaultText)
{   
    if (field.getDisplayedValue() == defaultText)
    {
        field.setDisplayedValue('');        
    }   
}

function resetElement(field, defaultText)
{       
    if (field.attr('value') == "")
    {
        field.reset();  
    }
}

I also tried passing just the event but looking through the fields shown in FireBug I wasn't able to find anything that says clicked on TextBox vs clicked on Arrow Dropdown icon