Topic: Effects on revisit of a page

Hello,
I am using Prototype.js and Effects.js with a form I am developing and have run into an issue.  The effects are working fine on the initial run of a page. The behavior of the form hides certain fields depending on the value of a radio button.  If the elements are hidden, and a user leaves the page, and then returns to the page, elements are again visible.  The radio buttons are maintaining their values upon returning to the initial page.  I am also attempting to use the same functionality with checkboxes.

My checkbox code in the view is :
<%= check_box :applicantaad, :declined, {:onClick => "new Effect.toggle('hideMe1')", :checked => "new Effect.toggle('hideMe1')"}, '1', '0' %>

and my radio button code is:
<%= radio_button :applicantreferrald, :referraltyper_id, :'1', :onClick => "new Effect.Appear('detailHide')" %>
<%= radio_button :applicantreferrald, :referraltyper_id, :'2', :onClick => "new Effect.Fade('detailHide')" %>

where 'hideMe1' and 'detailHide' are <div> tags

Any suggestions would be appreciated greatly.
Thank you

Re: Effects on revisit of a page

Do you mean return to the page as in using your browser's back button to go back to the page, or as in clicking on a link that goes back to the page?

If you're using the browser's back button (or javascript to step back through the browser history), then the form field values are going to be remembered by the browser, hence the reason your radio buttons aren't being reset.

Either way, a no-cache directive in the header might fix this.

Re: Effects on revisit of a page

Thank you Kelli,
I ended up resolving this by changing my onLoad call to call a function that combined the stuff to make my validation work and field checkers for the effects.

in my view I put

<body onload="onloadCombinerp2()">


and in my javascript, I put:
function onloadCombinerp2() {
// this function loads the validity checker and makes fields visible or not visible dependent upon the status of the check box and referral type radio buttons on page 2
  var v = new Validation('page1', {immediate:true, useTitles:true});
 
  chkbox = document.getElementById('applicantaad_declined');
  if (chkbox.checked == true) { 
    new Effect.toggle('hideAA'); 
  }
 
  radio1 = document.getElementById('applicantreferrald_referraltyper_id_1');
  radio2 = document.getElementById('applicantreferrald_referraltyper_id_2');
  radio3 = document.getElementById('applicantreferrald_referraltyper_id_3');
  radio4 = document.getElementById('applicantreferrald_referraltyper_id_4');
  radio5 = document.getElementById('applicantreferrald_referraltyper_id_5');
  radio6 = document.getElementById('applicantreferrald_referraltyper_id_6');
  radio7 = document.getElementById('applicantreferrald_referraltyper_id_7');
 
  if(radio1.checked == true || radio2.checked == true || radio3.checked == true
      || radio4.checked == true || radio5.checked == true
      || radio6.checked == true || radio7.checked == true) {
        new Effect.Squish('detailHide');
        }
   
  if(radio1.checked == true) {
    new Effect.Squish('detailHide');
  }
    if(radio2.checked == true) {
    new Effect.Squish('detailHide');
  }
    if(radio3.checked == true) {
    new Effect.Grow('detailHide');
  }
    if(radio4.checked == true) {
    new Effect.Squish('detailHide');
  }
    if(radio5.checked == true) {
    new Effect.Squish('detailHide');
  }
    if(radio6.checked == true) {
    new Effect.Squish('detailHide');
  }
    if(radio7.checked == true) {
    new Effect.Grow('detailHide');
  }
}

I included the whole of my method since it has radio buttons and checkboxes and felt somebody else might be helped by this