[SOLVED] Form Javascript | Passing data from a Form to another

marcq

Member
Hi,

I have a form 58 in which I have created a button element to open another form 44 in which I would like to inherit some field values from form 58.

Therefore I have created a JS file which enable me to get the needed value and to open form 44 into another windows :
JavaScript:
function inheritForm58ToForm44() {

    // GET FORM REFERENCE
    var form1 = Fabrik.getBlock('form_58');
    var form2 = Fabrik.getBlock('form_44');

    // GET VALUES
    var url_cp_name = form1.formElements.get('gprh_fabrik_user_registration___cp_name').getValue();
    var url_cp_firstname = form1.formElements.get('gprh_fabrik_user_registration___cp_firstname').getValue();
    var url_cp_zip = form1.formElements.get('gprh_fabrik_user_registration___cp_zip').getValue();
    var url_cp_city = form1.formElements.get('gprh_fabrik_user_registration___cp_city').getValue();
    var url_cp_email = form1.formElements.get('gprh_fabrik_user_registration___cp_email').getValue();

    // OPEN FORM 44
    window.open("http://www.webamazingapps.com/projects/gprh.ch/index.php/gestion-membres-2/suivi-administratif/gestion-courriers-rappel/creer-un-courrier-rappel-sa");

    // UPDATE FIELDS IN FORM 44

How can I for example populate the form 44 'gprh_fabrik_user_reminder___bloc_destinataire' with the getValue of 'url_cp_email'.

Thank you in advance for your support.

Cheers,

marc
 
Assuming it's a new form, just append them as query strings ...

Code:
    window.open("http://www.webamazingapps.com/projects/gprh.ch/index.php/gestion-membres-2/suivi-administratif/gestion-courriers-rappel/creer-un-courrier-rappel-sa?othertable___cp_name=" + url_cp_name + "&othertable___cp_firstname=" + url_cp_firstname + "etc etc");

Just replace othertable___cp_name (etc) with the full element names on the other form.

-- hugh
 
Thank you Hugh it works, cheers, marc

For whom it could be usefull, how to set a radio button value with the url :

Code:
// SET VALUE
var type = 1;

+ '&gprh_fabrik_user_reminder___type_rappel=' + type
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top