Jump to content


This topic is now archived and is closed to further replies.


Populate QuickForm field from popup

Recommended Posts

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:

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

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.


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

[code=php:0]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');

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.