correct fields

vismay 31 Mar, 2013
Hello,
I have a question about information stored in fields:

there is a dropbox where the user choose where he lives ( secondary fields are shown after a javascropt):

italian-> city and province
foreign-> country and city

then in the next page there is a confirmation page where all values are showed.

So, for example if he choose italian, there is : name, surname, city , province.

Let's say that he commit an error, he wan to to choose foreign.

In the confirmation page the results now are: name, surname, city, province, country, city.

Because probably the system remember the past choice and shows now everything.

Is there a string to refresh or cancel this value?

I've tryied already, the "show HTML republish from data", but doesn't work.


Thanks for help

Matteo
GreyHead 31 Mar, 2013
Hi Matteo,

I'm sorry I don't understand your question?

Exactly where is the past choice being remembered?

Bob
vismay 31 Mar, 2013
Sorry,

it's not easy to explain!!!

so, the form is multipage, let's say 3:

1st page:
booking details

2nd page:
name, surname etc...
and this dropdown choice
place of birth:

<fieldset class="cf_container ccms_form_element " id="cf_container_53"><legend>Luogo di Nascita e residenza</legend>
<div class="ccms_form_element cfdiv_select multiline_start" id="luogo_di_nascita_container_div" style=""><label for="luogo_di_nascita">Luogo di nascita</label><select size="1" id="luogo_di_nascita" class="" title="" name="luogo_di_nascita">
<option value="ci">Comune italiano: Comune e provincia</option>
<option value="se">Stato estero: Stato e citta'</option>
</select>
<div class="clear"></div><div id="error-message-luogo_di_nascita"></div></div>
<div class="ccms_form_element cfdiv_text multiline_add" id="comune_nascita_capo_container_div" style=""><label for="comune_nascita_capo" style="display:none;">comune</label><input id="comune_nascita_capo" maxlength="150" size="30" class=" validate['required','alpha']" title="" type="text" value="" name="luogo_di_nascita_comune" />
<div class="clear"></div><div id="error-message-luogo_di_nascita_comune"></div></div>
<div class="ccms_form_element cfdiv_select multiline_add" id="provincia_nascita_capo_container_div" style=""><label for="provincia_nascita_capo" style="display:none;">provincia</label><select size="1" id="provincia_nascita_capo" class=" validate['required']" title="" name="luogo_di_nascita_provincia">
<option value="">--</option>
<option value="AG">AG</option>
<option value="AL">AL</option>
....
</select>
<div class="clear"></div>
<div id="error-message-luogo_di_nascita_provincia"></div></div>
<div class="ccms_form_element cfdiv_text multiline_add" id="stato_nascita_capo_container_div" style=""><label for="stato_nascita_capo" style="display:none;">stato</label><input id="stato_nascita_capo" maxlength="150" size="30" class=" validate['required','alpha']" title="" type="text" value="" name="luogo_di_nascita_stato" />
<div class="clear"></div><div id="error-message-luogo_di_nascita_stato"></div></div>
<div class="ccms_form_element cfdiv_text multiline_add" id="citta_nascita_capo_container_div" style=""><label for="citta_nascita_capo" style="display:none;">citta</label><input id="citta_nascita_capo" maxlength="150" size="30" class=" validate['required','alpha']" title="" type="text" value="" name="luogo_di_nascita_estero" />
<div class="clear"></div><div id="error-message-luogo_di_nascita_estero"></div></div><div class="ccms_form_element cfdiv_custom" id="hr1_container_div" style=""><hr><div class="clear"></div><div id="error-message-hr"></div></div>


the selection of the field is then decided from a script:
window.addEvent('domready', function() {
  var select, other;
  select = $('luogo_di_nascita');

  switchOther();
  select.addEvent('change', switchOther);
  function switchOther() {
    if ( select.value == 'ci' ) {
comune_nascita_capo.disabled = false;
      provincia_nascita_capo.disabled = false;
      comune_nascita_capo.hidden = false;
      provincia_nascita_capo.hidden = false;
      stato_nascita_capo.value = '';
      stato_nascita_capo.hidden = true;
stato_nascita_capo.disabled = true;
      citta_nascita_capo.value = '';
      citta_nascita_capo.hidden = true;
citta_nascita_capo.disabled = true;
    } else {
stato_nascita_capo.hidden = false;
citta_nascita_capo.hidden = false;
stato_nascita_capo.disabled = false;
citta_nascita_capo.disabled = false;
      comune_nascita_capo.value = '';
      comune_nascita_capo.hidden = true;
comune_nascita_capo.disabled = true;
      provincia_nascita_capo.value = '';
      provincia_nascita_capo.hidden = true;
provincia_nascita_capo.disabled = true;
    }
  }
});


THen the user go to the next page ( actually there are more pages...) wher he has to check the informations.

Of course I use:
<p><strong>Luogo di Nascita: </strong>{luogo_di_nascita_comune} {luogo_di_nascita_provincia} {luogo_di_nascita_estero} {luogo_di_nascita_stato}</p>


And it shows me only what it was choosen. Until now it's OK.

But if the user made a mistake and goes back to choose the second choice ( example foreign land and country and city), when it goes to confirmation page it shows ALL values, the one of the first choice and the one of the second choice.

It's like the system remember the past values.
vismay 01 Apr, 2013
Any idea? 😟
GreyHead 01 Apr, 2013
Hi vismay,

I think that this is just a question of being logical . . .

When the user moves between pages the form data is saved in the User session, if they have a value for luogo_di_nascita_provincia set then that will be saved. If they then go back and change to luogo_di_nascita_estero that will also be saved because they have different names.

Your script needs to deal with this by setting luogo_di_nascita_provincia to '' when a value for luogo_di_nascita_estero is set (and vice versa).

It looks as though you have some of this already BUT if an input is disabled it is not included in the $_POST array when the form is submitted and so will not over-write any existing value. If you want the inputs cleared then set the value to '' and leave them enabled but hidden.

Bob
vismay 01 Apr, 2013
This sounds good to me!
THanks I will try!!!

Basically I need to cancel the function

stato_nascita_capo.disabled = true;
vismay 01 Apr, 2013
Only problem, doesn't let my go further because the hidden field then is compulsory and cannot be empty!!!
GreyHead 01 Apr, 2013
Hi vismay,

Then Max's approach of using a ghost input may work.

Add a hidden input with the same name (but a different id) into the form *before* the real input. Then if the real input is disabled the hidden the value of the hidden input will be submitted.

Bob
vismay 01 Apr, 2013
Thanks for help, but this idea is not working....

Do you think is possible to insert a validation in the javascript, so I leave it free in the chronoform easywizard, but mandatory in javascript?

window.addEvent('domready', function() {
  var select, other;
  select = $('luogo_di_nascita');

  switchOther();
  select.addEvent('change', switchOther);
  function switchOther() {
    if ( select.value == 'ci' ) {
      comune_nascita_capo.hidden = false;
      provincia_nascita_capo.hidden = false;
      stato_nascita_capo.value = '';
      stato_nascita_capo.hidden = true;
      citta_nascita_capo.value = '';
      citta_nascita_capo.hidden = true;
    } else {
stato_nascita_capo.hidden = false;
citta_nascita_capo.hidden = false;
      comune_nascita_capo.value = '';
      comune_nascita_capo.hidden = true;
      provincia_nascita_capo.value = '';
      provincia_nascita_capo.hidden = true;
    }
  }
});
GreyHead 01 Apr, 2013
Hi vismay,

You can enable and disable the validations using the FormCheck register() and dispose() methods. The ghost would be much simpler to do :-(

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