0

hi,
i have a page which shows user details(div1) by default
there will be an admin who enters username and pwd and then a new div(div-layer) is displayed.
also ,a user can edit his data by pressing edit button on which he will be displayed div2 and div1 will be hidden.
mt problem is when i try checking all these one by one they work perfectly except for when i enter admin username and pwd and tell a user to fill in more details and then assume myself as a user and edit the data...at this point when i go back(i mean press back button on mozilla browser)...all my divs are visible(even the div layer which should be visible after admin authentication) irrespective of their display settings.i tried disabling the back button..but mozilla doesn't allow js to modify that.please suggest a solution.

<html>
<head>
<script type = \"text/javascript\">
function hideDiv(which) {
if (which == 1) {
document.getElementById(\"div1\").style.display=\"block\";
document.getElementById(\"div2\").style.display=\"none\";
}
if (which == 2) {
document.getElementById(\"div2\").style.display=\"block\";
document.getElementById(\"div1\").style.display=\"none\";
window.history.forward(1);
}
}
</script>
</head>
<body>
<div id="divedit">
<input value=\"edit\" type=\"button\" name=\"edit\" onClick= \"hideDiv(2);\"/>
.........
</div>
<div id="div1">
........
</div>
<div id="div2">
........
</div>
<div id="div3">
username:<input type="text" name="uname"/></br>
password:<input type="password" name="uname"/>
<input value="submit" type="submit" name="submit"/>
</div>
<div id="layer" class="layer" style="display:<?php if(isset($_POST['submit'])) {echo (($_POST['uname'] =='deepthi' && $_POST['pwd']=='deepthi')? 'block' : 'none'); } else {echo 'none';} ?>;">
.....
<body>
</html>

Edited by saideepthi.bits: n/a

3
Contributors
7
Replies
8
Views
6 Years
Discussion Span
Last Post by saideepthi.bits
0

you should post this in the javascript area of this website

yes, but my problem is ...in display:none,i have written a php check function which is not executing when back button is pressed...i mean it should check the condition every time the page is loaded right..?is hitting back button on your browser not equivalent to loading the page..? plz help...thanx in advance

0

The back button tries to reload the previous page exactly as it was. Theoretically it should refire the php but given I've never had this problem, or tried doing it this way, I can't say it will work perfectly. This is also a js problem, not a php as php doesn't have any control over a page once it's been downloaded (is being viewed).

However, a possible solution would be to initially change all the div's display to none and then update from there. Or you can use jQuery.

[Links]
http://www.jquery.com/

Edited by Nyight: n/a

0

The back button tries to reload the previous page exactly as it was. Theoretically it should refire the php but given I've never had this problem, or tried doing it this way, I can't say it will work perfectly. This is also a js problem, not a php as php doesn't have any control over a page once it's been downloaded (is being viewed).

However, a possible solution would be to initially change all the div's display to none and then update from there. Or you can use jQuery.

[Links]
http://www.jquery.com/

so, you are basically saying that doing this in js will be a better idea...but my problem is that i take username and password and match them to admin data and then display the div ...anyways i'll try js and get back to you...thanx

0

Truthfully I have no idea what you're trying to accomplish with the admin concept or why you have everything in your posted code commented out. I assumed your problem was that everything became visible when you clicked the back button. A simple solution to that would be to set everything to hidden at the top of the page (the very first thing js does) and then check to see if it should be shown.

0

Truthfully I have no idea what you're trying to accomplish with the admin concept or why you have everything in your posted code commented out. I assumed your problem was that everything became visible when you clicked the back button. A simple solution to that would be to set everything to hidden at the top of the page (the very first thing js does) and then check to see if it should be shown.

oh sorry..i didnot notice "\" . now my problem is that i have declared the display of the divs hidden and it works fine except for when i am navigating through the pages and hit back button on the browser, i see all the divs even those which are supposed to be hidden.

0

Truthfully I have no idea what you're trying to accomplish with the admin concept or why you have everything in your posted code commented out. I assumed your problem was that everything became visible when you clicked the back button. A simple solution to that would be to set everything to hidden at the top of the page (the very first thing js does) and then check to see if it should be shown.

hi, thanx a lot..."declaring div display initially in js and calling the function on form onload" solved my problem....i havent got time to reply back...thanx again

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.