PHP variable - assign a value Using JavaScript

sabecs
sabecs used Ask the Experts™
on
Hi,
How do I reload a page so that I can set a PHP variable?

The code below triggers when a checkbox is checked, I then need to reload the page to set a PHP variable.

function pickup(pickup){
            if (pickup.checked == 1){
            document.getElementById('showmessage').style.display = 'none';
            document.getElementById('showbuttons').style.display = 'inline';
            //code to reload page here and POST or GET a variable that I can pickup and assign using PHP

            }else {
            document.getElementById('showmessage').style.display = 'inline';
            }

}

Thanks in advance for your feedback.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Engineering Manager
Commented:
Hope this helps
<?php
   $pickup=$_POST['pickup'];
   echo "pickup".pickup;
?>

function pickup(pickup){
            if (pickup.checked == 1){
            document.getElementById('showmessage').style.display = 'none';
            document.getElementById('showbuttons').style.display = 'inline';
            document.forms[0].method="post";
             document.forms[0].submit();

            //code to reload page here and POST or GET a variable that I can pickup and assign using PHP

            }else {
            document.getElementById('showmessage').style.display = 'inline';
            }

}

Open in new window

Umar Topia.Net Full Stack Developer

Commented:
window.location.href = "your page url";
function pickup(pickup){
            if (pickup.checked == 1){
            document.getElementById('showmessage').style.display = 'none';
            document.getElementById('showbuttons').style.display = 'inline';
            //code to reload page here and POST or GET a variable that I can pickup and assign using PHP
            window.location.reload(true);

            }else {
            document.getElementById('showmessage').style.display = 'inline';
            }

}

Author

Commented:
Thanks shinuq.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial