function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Deepak ChouhanDeepak Chouhan 

div show or hide in visualforce page but page reload when button onclick event

Hi,
i have crated vf page with 6 div section..
$(document).ready(function () {   
              $('.step2, .step3, .step4, .step5, .step6').hide();   
               
        });
        function showStep(step_name){
                if(is_validate && is_valid){
                    $('.step, .step2, .step3, .step4, .step5, .step6').hide();
                    $('.'+step_name).fadeIn();
            }
        } 

<div class"step">          
                <apex:commandButton value="Next" onclick="showStep('step3'); return false;"/>
some field is here......
</div>

<div class"step2">
                <apex:commandButton value="Back" onclick="showStep('step'); return false;"/>
                <apex:commandButton value="Next" onclick="showStep('step3'); return false;"/>
some field is here......
</div>

<div class"step3">
                <apex:commandButton value="Back" onclick="showStep('step'); return false;"/>
                <apex:commandButton value="Next" onclick="showStep('step3'); return false;"/>
some field is here......
</div>

and so on
when i click the next button vf page reload....
pls help me out
 
Best Answer chosen by Deepak Chouhan
Jigar.LakhaniJigar.Lakhani
Hello Deepak,

Please try to find Javascript error in browser console using "ctrl+shift+j", may be there is some error.

I have tried your code in my developer organization with minor below change, and it works fine. Page was not reload.
function showStep(step_name){
                    $('.step, .step2, .step3, .step4, .step5, .step6').hide();
                    $('.'+step_name).fadeIn();
        }
I have removed "is_validate && is_valid" if condition. and It works fine.
Try it.

Thanks & Cheers,
Jigar