Show/hide Div Section Based On Where The Page Is Redirected From?
Solution 1:
Add a query string parameter to your URL and have the page show or hide the div based on the query string parameter.
For example,
header('Location: usrsecuredpage.php?ShowDiv=true');
Then, in the resulting page, you can check the value of that variable by using the global variable $_GET, like this:
$_GET['ShowDiv']
Using this variable, you can show or hide the div accordingly. Let me know if I can provide any more detail...
Solution 2:
I would recommend using jquery for this if you can ... Just include the jquery library and then use this code ...
$("#yourDiv").show();
Solution 3:
Use GET parameters that you can pass through the URL. For example, in your PHP file which redirects back to the original page, type the following for your redirection code:
header('Location: usrsecuredpage.php?div=sub'); // div='sub' or div='stu'
Now, in the usrsecuredpage.php
file, include the following code near the top to find out which div to have open at the start:
$openDiv = $_GET['div'];
At this point the $openDiv
variable will contain either 'sub', 'stu', or will not be defined (if you didn't include the parameter in the URL). You can use isset($openDiv)
to find out whether it is defined or not. If it is defined, then compare against the value of $openDiv to find out which div to have open at the start. For example:
// initialize display of both divs to none
$subscriptionVisibility = "none";
$stusearchVisibility = "none";
// now, based on value of $openDiv, set above vars
if (isset($openDiv) && strcomp($openDiv,"sub") == 0)
$subscriptionVisibility = "inline";
else if (isset($openDiv))
$stusearchVisibility = "inline";
.
.
.
// now, whenever you create the divs, use their visibilities
echo "<div class='jotform-form' id='subscriptionDiv' style='display:$subscriptionVisibility;'></div>";
echo "<div class='jotform-form' id='stusearchDiv' style='display:$stusearchVisibility;'></div>";
In this example if your parameter was anything other than 'sub', the code assumes it was 'stu'. So if your parameter was 'bla', it would still make the stusearch div visible.
This may not be the best code for this solution, however, it should be enough to push you in the right direction. The overall approach is: pass the parameter in the URL string as a GET parameter (as I have shown), and then, in the usrsecuredpage.php
file, use that parameter to determine which div should be open from the start.
Post a Comment for "Show/hide Div Section Based On Where The Page Is Redirected From?"