Jump to content


Photo

Populate QuickForm field from popup


  • Please log in to reply
No replies to this topic

#1 paulgami

paulgami
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 17 August 2006 - 04:20 PM

I'm working from one of the examples that comes with PEAR's HTML_QuickForm_Controller (1.0.6) - regWizard.php and all is fine.

However, I'd like to add a feature where I present the user with a link that opens a popup to get some information, and then returns the user to the form that now has one of its textfields populated with the result of the processing in the popup.  Using a similar method to how some travel sites will have a calendar popup in order to fill in a date field.

The relevant portion of the code:


$this->addElement('link','enginepopup','Choose your engine','enginechoice.php','click here');
$this->addElement('text','engineModel','Engine Model', array('size' => 30, 'maxlength' => 63));


I'd like for a user to click on the 'enginepopup' link, and have that popup pass back the result into the following text element 'engineModel'.

Is that possible?  I suspect some javascript is involved, but I'm not sure where to start.  I'd appreciate any information.

Thanks


The full class for that step of the "wizard":

class Aircraft_Information extends HTML_QuickForm_Page
{

    function buildForm()
    {
        $this->_formBuilt = true;

        $this->addElement('header', 'data_header', 'Aircraft Information');
        
        $this->addElement('text', 'aircraftMfr', 'Aircraft Manufacturer', array('size' => 30, 'maxlength' => 63));
        $this->addElement('text', 'aircraftModel', 'Aircraft Model', array('size' => 30, 'maxlength' => 63));
        $this->addElement('text', 'aircraftYear', 'Aircraft Year', array('size' => 30, 'maxlength' => 63));
        $this->addElement('text', 'aircraftRegNo', 'Aircraft Registration No.', array('size' => 30, 'maxlength' => 63));
        $this->addElement('text', 'aircraftSerNo', 'Aircraft Serial No.', array('size' => 30, 'maxlength' => 63));       
 
        $this->addElement('link','enginepopup','Choose your engine','enginechoice.php','click here');
        $this->addElement('text','engineModel','Engine Model', array('size' => 30, 'maxlength' => 63)); 

        $prevnext[] =& $this->createElement('submit',   $this->getButtonName('back'), '<< Previous step');
        $prevnext[] =& $this->createElement('submit',   $this->getButtonName('next'), 'Next step >>');
        $this->addGroup($prevnext, 'buttons', '', '&nbsp;', false);
        
        $this->addRule('aircraftRegNo', 'Aircraft Registration No. is required', 'required');
        $this->addRule('aircraftSerNo', 'Aircraft Serial No. is required', 'required');
        
        $this->setDefaultAction('next');
    }
}





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users