Data to session - Unset one of the fields when pressing the back button in the browser

danaviziteu 12 Aug, 2014
I use Data to session action to pass data from one form (FORM 1) to another form (FORM 2). When I press the Back button to go back from FORM 2 to FORM 1, all the fields in FORM 1 remain filled in, but i need one of the fields to be cleared, so the user will have to write again its value.
GreyHead 12 Aug, 2014
Hi danaviziteu,

You can add a Custom Code action after the Session to Data action to unset a value:
<?php
$form->data['some_input'] = '';
?>

Bob
danaviziteu 12 Aug, 2014
I've tried this, but it will unset the field only on refresh of the FORM 1 page. I need it to be unset by clicking the back button in the browser also.
GreyHead 13 Aug, 2014
Hi danaviziteu,

Then I think that you would need to do that somehow with JavaScript. ChronoForms doesn't 'see' the form in that case so can't do anything. In MooTools the script would be something like:
window.addEvent('domready', function() {
  $('input_id').value = '';
});
That should clear the value whenever the page loads.

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