Posting data from PHP popup in Smarty form

I am adding Experian Quick Address zip view to client website using javascript / PHP popup on website with Smarty template.

Does anyone know how to send data from a popup back to a Smarty form?

Form process:

  • The client is sent to the request form (Smarty template)
  • Client clicks on "Get my address" button (activates the js / php popup)
  • The client looks at the address and accepts the address (close the popup)
  • The data from the popup is displayed in the address fields on the form
  • The form is submitted with the usual message {IF $ SUCCESS}

I am stuck on number 4, so any guidance would be greatly appreciated!

+3


source to share


1 answer


You can do this quite easily using the window.opener property in the JavaScript popup.

After you get the data you want in the popup, you can revert it back to its original form from the Smarty page like this:

window.opener.document.getElementById('form_zip_code').value = quick_postcode;

      



There are several ways to access a form element, but this is the simplest and works without using jQuery, Prototype or any JS library functions.

Hope it helps.

+3


source







All Articles