Welcome! Log In Create A New Profile

Advanced

Stuck... Again...

Posted by 49459635 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Stuck... Again...
September 03, 2012 08:50PM
So I'm back here again, stuck on another issue. This one has had me stumped for a while now. I think it's caused by a lack of sleep, or at least, that contributes to the reason I can't seem to find the answer...

I have a hidden form on the page that has a hidden field, and a specific value set. The action param is empty, so I'm basically doing the postback to the page itself and right at the top of the page I have this:

Language: PHP
if (isset($_POST[';hiddenfieldname';]) && $_POST[';hiddenfieldname';] == ';specificvalue';) { //It does something here I don';t want to give away }

Now anyone who's actually worked on this assignment a bit, should figure out what I'm doing here rather easily. My problem is rather obscure, this works *sometimes*. I have a button that submits the form by doing this (Yes it's in javascript since I'm using images...):

Language: Javascript
function LogOut(formName){ obj = document.getElementById(formName); if (obj != null) obj.submit(); }

Now I've checked rechecked and then checked again that I'm not getting any JS errors, so pretty sure this isn't a timing issue in terms of page load. Sometimes it works with the first click, other times it works on the 2 or even 3rd click. When it doesn't work, I can see the postback occuring but it's like the code doesn't fire. I've added an echo and when it doesn't work, the echo isn't displayed either. So not completely sure what to make of it, does anyone have any suggestions?
avatar
Mac
Re: Stuck... Again...
September 04, 2012 07:26AM
Not knowing the rest of your code it is difficult to pinpoint. Get rid of the javascript and use HTML to include a button. Why test two conditions on submit - just use the last one.
Re: Stuck... Again...
September 04, 2012 08:00AM
Good spot, thanks. NullReference habits smiling smiley

Thanks Mac, I'll swap that out and see if the results are more consistent. I have a feeling I might have code on another page interfering here, since I'm going with a template approach and including quite a bit of other files... I have a feeling a JS error would have felt more like a JS error.

In the meantime I've added $debug to the config and spammed a couple of files with things like:

Language: PHP
if ($GLOBALS["debug"] == 1) { echo "<h1>Session Value : ". $_SESSION[';adminuser';] ."</h1>"; }

Hopefully that helps me get to the bottom of the issue.
Sorry, only registered users may post in this forum.

Click here to login