Jump to content

Populate QuickForm field from popup


paulgami

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.

Thanks


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');
       
        $this->setDefaultAction('next');
    }
}[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.