Forums

Multi page copy field value from one page to the next

celevt 08 May, 2013
Form: http://www.celevt.nl/formtest

Hi,

I have a Multi page form which functions just fine. I need however to copy data from one page to the next based on the users choice in a checkbox on the previous page.
The java examples on the website works like a charm but only if you copy data on the same page. I’am now wondering how to do this with a multi page form.

Kind regards,
CELEVT
GreyHead 08 May, 2013
Hi celevt,

The Multi-Page action will carry the data forward for you.

Please see this FAQ

Bob
celevt 08 May, 2013
Hi Bob,

Thanks for the swift reply. I used the FAQ to create the form and the multi page setup works like a charm :-).
However when the checkbox on the first page is clicked the data on the next page is not updated. When I use the script below for an field on the same page it all works fine, but when the field is on the next page nothing is updated. I must be missing something here... could you have a look at the simplified script below?
window.addEvent('domready', function() {
  $('copy_ctod').addEvent('click', function() {
    if ( $('copy_ctod').checked ) {	
   $('d_voornaam.value').value = 'TEST OF SCRIPT WERKT';
    }
  });
});
GreyHead 08 May, 2013
Hi celevt,

I'm sorry, I'm lost . . . What exactly is the problem. That the checkbox isn't checked on the second page - or the JavaScript doesn't work when the checkbox is clicked?

Bob
celevt 08 May, 2013
Hi Bob,

I gues the JavaScript does not work. When the checkbox is clicked on the first page à value should be entered into à field on the second page.

I hope this is clear enough of you need more info please ask again.

Kind regars,
Bart
GreyHead 08 May, 2013
Hi Bart,

Please drag a Debugger action into the On Load event on the second form, then submit the first form and post the debug results here.

Bob
celevt 08 May, 2013
Hi Bob,

Below you will find the debugger information of the page two event. I'am a bit suprised that[d_voornaam] is not in the array while a value is set in the java script.

Any ideas?

Thanks,
Bart

Array
(
[chronoform] => mcpov4
[event] => Pagina twee
[cf_sid] => 3f8a53e2e58d7947ec90b97cc17c4690
[Itemid] => 201
[option] => com_chronoforms
[view] => form
[a_referentiecode] =>
[a_evenement] => Masterclas duplo voor gevorderden
[a_datum] => 01-01-9999
[a_prijs] => Prijs
[c_voornaam] => cx vc
[c_achternaam] => zxcmnvznx
[c_organisatie] => zxnvcmz
[c_telefoon] => 888
[c_email] => [email]bwboerman@gmail.com[/email]
[copy_ctod] => 1
[input_submit_5] => Volgende
[d2877cf131816cdb5922c1f991b72057] => 1
)
Validation Errors:
Array
(
)
GreyHead 08 May, 2013
Hi Bart,

I don't think that there is an input with the name or id of d_voornaam in the first form; there is a c_voornaam though.

Bob
celevt 09 May, 2013
Hi Bob,

That's correct lol :? ..

However what I want to achieve is a update of d_voornaam on page 2 based on c_voornaam on page 1. Is this possible?

The script works if I update c_voornaam but does not achieve updating a field on page 2.

Kind regards,
Bart
GreyHead 09 May, 2013
Hi Bart,

In the On Submit event of the first form add this code snippet:
<?php
$form->data['d_voornam'] = $form->data['c_voornam'];
?>
That should to it.

Bob
celevt 09 May, 2013
Hi Bob,

Almost there… The data is entered into the data array, d_voornaam is now populated with the value from c_voornaam in the previous page.
But the value is not displayed in the form field d_voornaam.

Best regards,
Bart


Data Array:
Array
(
[chronoform] => mcpov4
[event] => Pagina twee
[cf_sid] => 3185d11b84b8cf5a00299fd33c533b48
[Itemid] => 201
[option] => com_chronoforms
[view] => form
[a_referentiecode] =>
[a_evenement] => Masterclas duplo voor gevorderden
[a_datum] => 01-01-9999
[a_prijs] => Prijs
[c_voornaam] => Bart
[c_achternaam] => bbb
[c_organisatie] => bbb
[c_telefoon] => 888
[c_email] => [email]bwboerman@gmail.com[/email]
[copy_ctod] =>
[input_submit_5] => Volgende
[3e0db2e081b6f1ebe53a1775547c00ea] => 1
[d_voornaam] => Bart
)
Validation Errors:
Array
(
)
GreyHead 09 May, 2013
Hi celevt,

It all looks OK. Is the Republisher set on in the Show HTML action? (it should be by default). And is the Session to Data action in Form 2 before the Show HTML action?

Bob
celevt 10 May, 2013
Hi Bob,

Cheers 🤣 , thanks for your advise

Solution:

Republisher set on in the Show HTML action for page 2, disabled for page 1 for privacy reasons
Session to Data action for page 2 before the Show HTML action
Custom php code for page 2 before the session to data

Php code (based on radio box)
<?php
if ( $form->data['c_cisd']='Ja' ) {
$form->data['d_voornaam'] = $form->data['c_voornaam'];
}
?>
GreyHead 10 May, 2013
Hi celevt,

The PHP needs an extra = in the if clause
<?php
if ( $form->data['c_cisd'] == 'Ja' ) {
  $form->data['d_voornaam'] = $form->data['c_voornaam'];
}
?>

But I don't think that is causing the problem.

Bob
This topic is locked and no more replies can be posted.