EasyCFM.COM ColdFusion Forums / Coding Help! / Disable *GASP* Refresh Button?

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: Disable *GASP* Refresh Button?

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

][ce
07-10-2004 @ 12:50 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 25
Joined: Jul 2003

Hey everybody!

This is more of a suggestion request, than a question.... so here my scenario!:

I am building a web application for two call centres that will allow representatives to take monthly tests.  The application is completely built, and I'm just working on validation and locking the app down.

The problem is this... I have the questions and answers randomizing everytime the form is loaded, to ensure test integrity.  Although, if somebody partially completes the test, and decides to start over, clicking refresh re-randomizes the test.  I would prefer that they simply click the Reset button, clearing the answers and keeping the questions/answers in the original order of that instance.

I already have a onbeforeunload warning, letting them know that all changes will be dropped, but you really have to hold these people by the hand sometimes.

The only solution I can think of is capturing "F5" for refresh... and then just returning the keyEvent to nothing.  But I also heard that coldufsion can disable refresh all together.
Oh... also, the application is in a popup window, so there is no standard button toolbar... so no worries on disabling the actual button.

Does this make any sense?
Any help would be truly appreciated.
Thanks in advance.

Dave



Webmaster
07-10-2004 @ 1:00 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Administrator
Posts: 4542
Joined: Jan 2002

I would go a different route Smile

Create a table called "MEMBER_Test" or something like.

Here define a few things..

1) member_id
2) test_question_id
3) sort_orderID

then when they start the test (send them to a page that says.. please wait, we are building your test).. then at that point populate the table with random numbers for test_question_id, and put them in order (from question 1 to the last one).. this will basically make it so if they hit refresh it wont matter... it will also take care of allowing re-testing.

follow?

Thanks,
Pablo Varando
Team Macromedia Member
=====================================================

megan
07-10-2004 @ 1:03 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 2398
Joined: Jan 2003

great idea! - had the js below in my snippets and posting it fwiw

solution that works in both IE and Netscape. Tested on IE6 and NS6.2

    function showDown(evt) {
        evt = (evt) ? evt : ((event) ? event : null);
        if (evt) {
            if (event.keyCode == 8 && (event.srcElement.type != "text"
&& event.srcElement.type != "textarea" && event.srcElement.type !
= "password")) {
                // When backspace is pressed but not in form element
                cancelKey(evt);
            }
            else if (event.keyCode == 116) {
                // When F5 is pressed
                cancelKey(evt);
            }
            else if (event.ctrlKey && (event.keyCode == 78 ||
event.keyCode == 82)) {
                // When ctrl is pressed with R or N
                cancelKey(evt);
            }
        }
    }

    function cancelKey(evt) {
        if (evt.preventDefault) {
            evt.preventDefault();
            return false;
        }
        else {
            evt.keyCode = 0;
            evt.returnValue = false;
        }
    }

    // Additional code for NS
    if (navigator.appName=="Netscape") {
        document.addEventListener("keypress",showDown,true);
    }
    document.onkeydown  = showDown;

~megan

Estne tibi forte magna feles fulva et planissima?

][ce
07-10-2004 @ 1:16 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 25
Joined: Jul 2003

Thanks Pablo and Megan!
That really helps a lot!

I initially built this application in VB, and that was the route I was using... a temporary field, for the sole purpose of sorting... although, I thought that was kind of "weak", for lack of better words.  Although, when you explained it, Pablo, it doesn't sound that bad.

The only problem I can see with that though, is, I still need to allow them to exit and re-take the test at a later date.  At which point, I would have to delete the old records, and re-populate them?

I could recognize that the records have already been inserted, and change my code from insert to update.

I guess I just don't want to go that route, because I finally got everything working with my question AND answer randomizing, and validation...  and was pretty proud of it. haha

I may have to consider going your route Pablo.
Grrrr

Thanks!
Dave

megan
07-10-2004 @ 2:46 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 2398
Joined: Jan 2003

Well it appears that the script above is throwing an error - here is another in my "collection" that I just tested and it works in ie6 and ns4.8 :

<Script language='javaScript'>
var isNS = (navigator.appName == "Netscape") ? 1 : 0;
var EnableRightClick = 0;
if(isNS)
document.captureEvents(Event.MOUSEDOWN||Event.MOUSEUP);
function mischandler(){
if(EnableRightClick==1){ return true; }
else {return false; }
}
function mousehandler(e){
if(EnableRightClick==1){ return true; }
var myevent = (isNS) ? e : event;
var eventbutton = (isNS) ? myevent.which : myevent.button;
if((eventbutton==2)||(eventbutton==3)) return false;
}
function keyhandler(e) {
var myevent = (isNS) ? e : window.event;
if (myevent.keyCode==96)
EnableRightClick = 1;
return;
}
document.oncontextmenu = mischandler;
document.onkeypress = keyhandler;
document.onmousedown = mousehandler;
document.onmouseup = mousehandler;
document.onkeydown = showDown;

//-->
function showDown()
{
if (document.all)
{
if (event.keyCode==116 || event.keyCode==82)
{
event.keyCode =0;
return false;
}
}
}
</script>


hth ~megan

Estne tibi forte magna feles fulva et planissima?

This message was edited by megan on 7-10-04 @ 2:46 PM


Website Designed and Developed by Pablo Varando.