Link to home
Start Free TrialLog in
Avatar of mock5c
mock5c

asked on

Triggering event from javascript

Here is my original question:

https://www.experts-exchange.com/questions/27833357/JavaScript-value-from-pop-up-window.html

I thought I had this solved, but now I realize that it does not work in Firefox.  It works in Chrome.

So now I'm stuck once again with why my button does not become enabled after a date is picked from the calendar control.

I've created a miniature version of my program and have reproduced the problem.

HTML code:
<head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
        <link rel="stylesheet" type="text/css" href="1-simple-calendar/tcal.css" />
        <script language="JavaScript" src="1-simple-calendar/tcal.js"></script>
        <script language="JavaScript" src="tcal_test.js"></script>
</head>
<body>
Name: <input type="text" id="name" name="name" value="" /><br />
<input type="text" autocomplete="off" id="scan_date" name="scan_date" class="tcal input" value="" />
<input type=submit id=btnSubmit name="submit" value="submit"></td>
</body>
</html>

Open in new window


tcal_test.js
function formValidation(oEvent){
        oEvent = oEvent || window.event;
        if(!oEvent){ return; } // Undefined oEvent did not work in Firefox.  Have to have this for FF.
        var txtField = oEvent.target || oEvent.srcElement;
        var chk=true;
        var msg=" ";
        var name = document.getElementById("name");
        var scan_date = document.getElementById("scan_date")
        if(name){
                if(name.value == ""){
                        chk=false;
                        msg = msg + "Please enter a name.";
                        name.focus = true;
                }
        }
        if(document.getElementById("scan_date")){
                if(scan_date.value == ""){
                        chk=false;
                        msg = msg + "Please select scan date.";
                        scan_date.focus = true;
                }
        }
        //alert(name + chk);
        // This check covers all controls
        if(document.getElementById("btnSubmit")){
                if(chk){
                        document.getElementById("btnSubmit").disabled = false;
                }
                else{
                        document.getElementById("btnSubmit").disabled = true;
                }
        }
};

window.onload = function () {
        var btnSubmit = document.getElementById("btnSubmit");
        if(btnSubmit){
                document.getElementById("btnSubmit").disabled = true;
        }
        if(document.getElementById("name")){
                var name = document.getElementById("name");
                name.onblur = formValidation;
                //name.onchange = formValidation;
        }
        if(document.getElementById("scan_date")){
                var scan_date = document.getElementById("scan_date");
                        //scan_date.onblur = formValidation;
                        scan_date.onchange = formValidation;
        }
        var chk=false;
};

Open in new window


I'm using Tigris calendar (1-simple-calendar):

http://www.softcomplex.com/products/tigra_calendar/tigra_calendar.zip

Then I made some modifications to the tigra caledar file tcal.js according to the link

http://www.softcomplex.com/forum/viewthread_5416/

The link suggested modifying the f_tcalCancel () function.  Before this modification, it did not work in Chrome.  After modification, it worked in Chrome but I did not test Firefox.  Now with firefox, I still have the problem.  It requires that after selecting a date, I have to select another text box and then blur out of that.

Please take a look and download my sample and see if there is a way to get this to work in Firefox.
ASKER CERTIFIED SOLUTION
Avatar of dnzone88
dnzone88
Flag of Malaysia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial