javascript - How to hide or display DIV based on checkbox state on different page? -


i have app in python django , there's summary page 5 sections. lets call them a, b, c, d, e. first 3 (a, b, c) generated automatically without doing anything. while last 2 (d, e) generated based on check-box state on different page.

i trying use jquery accomplish far have tried works if div's on same page. tried googling couldn't find solution.

$(".checkbox").click(function(e){     var checked = $(this).is(':checked');     if(checked==true){         //display content     } }); 

i can not pass url parameter because have button on same page check-boxes when clicked displays summary page in pdf format.

fyi: using hidden iframe on pages button (well button on 4 different pages) have content of summary page , shown pdf on button click.

use cookie easy , nice.

you can set cookie below , read through javascript

set cookie:

   document.cookie="checkbox=true"; 

read cookie on next page

   var value = readcookie('checkbox'); 

create function allows value each time

 function readcookie(name) {     var nameeq = name + "=";     var ca = document.cookie.split(';');     for(var i=0;i < ca.length;i++) {         var c = ca[i];         while (c.charat(0)==' ') c = c.substring(1,c.length);         if (c.indexof(nameeq) == 0) return c.substring(nameeq.length,c.length);     }     return null; } 

so when compare click can this:

$(".checkbox").click(function(e){     var checked = $(this).is(':checked');     if (checked == undefined || null){         checked = readcookie('checkbox');     }     if(checked==true){         //display content     } }); 

Comments