Experts Round Table Network

Clientside Technology => Javascript => Topic started by: thepreacher on June 11, 2007, 10:14:53 AM



Title: javascript error: - not implemented
Post by: thepreacher on June 11, 2007, 10:14:53 AM
I get the error "javascript error:-  not implemented" in IE in one of my scripts. according to the line number the problem is in the following sectiom of the the script
Code
Language: javascript (GeSHi-highlighted)
function calcSubtotal(f, s, w)
{
var amtWithdrawal = document.getElementById(w).value;
var exRate = document.getElementById(s).value;

alert(amtWithdrawal);
alert(exRate);
if ((exrate != "") && (amtWithdrawal != ""))
{
var subTotal = exrate * amtWithdrawal;
document.getElementById(w).value = subTotal;
}
}
 
function getExchrate(x, t, p, s, w)
{
if (!objRequest)
{
       getRequestobject();
}
 
var transcrncy = document.getElementById(t).value;
   var paycrncy = p;
   objRequest.onreadystatechange = handleHttpResponse2(x, s, w);
   var params = '?param1=' + transcrncy + '&param2='+ paycrncy;
   objRequest.open("GET", url2 + params, false);
   objRequest.send(null);
}
 
function handleHttpResponse2(fx, subt, wd)
{
alert(subt);
   if (objRequest.readyState == 4)
{
       if (objRequest.status == 200)
{
           var results2 = objRequest.responseText;
alert(results2);
           objRequest=null;
           var arr=results2.split(',');
alert(arr[2]);
           document.getElementById(fx).value = arr[2];
calcSubtotal(fx, subt, wd);
       }
   }

specifically in the following section:

Code
Language: javascript (GeSHi-highlighted)
function getExchrate(x, t, p, s, w)
{
if (!objRequest)
{
       getRequestobject();
}
 
var transcrncy = document.getElementById(t).value;
   var paycrncy = p;
   objRequest.onreadystatechange = handleHttpResponse2(x, s, w);
   var params = '?param1=' + transcrncy + '&param2='+ paycrncy;
   objRequest.open("GET", url2 + params, false);
   objRequest.send(null);
}

I'll appreciate any help please. Also if you can shed any light on the cause of the problem will be much appreciated.


Title: Re: javascript error: - not implemented
Post by: VGR on June 12, 2007, 12:06:28 PM
who cares about IE problems with standards ?


Title: Re: javascript error: - not implemented
Post by: Huntress on June 13, 2007, 03:03:09 AM
Would you care to elaborate VGR?


Title: Re: javascript error: - not implemented
Post by: Esopo on June 13, 2007, 06:33:58 PM
who cares about IE problems with standards ?

Roughly 85% of the e-world. What do you mean?



thepreacher,

Can you pin-point it to the exact line? (I'm sorry, I've never  seen this problem before)


Title: Re: javascript error: - not implemented
Post by: GrandSchtroumpf on June 14, 2007, 05:42:17 AM
> who cares about IE problems with standards ?
>> Roughly 85% of the e-world. What do you mean?

Not really.

On the client end, most users only care about having something that works.  If IE users cared abouts standards, they would simply stop using IE.

On the server end, most web developers only care about the standards, so they know their code will work on any standard-compliant browser/platform.  Most developers don't enjoy having to write special code for special browsers.

The only ones to care about standards in IE are the sales/marketing people who want both ends to work together.  If all sales/marketing people would suddenly disappear, I bet more developers would display some message like "please use a decent browser" when IE is detected.  Then users would stop using IE, and the web would be a much better place.


Title: Re: javascript error: - not implemented
Post by: VGR on June 14, 2007, 07:26:34 AM
Esopo, my measures on "grand public" (open audience?) websites show more  a 64/32 repartition, but things are different in the world (see maps like (http://www.xitimonitor.com/Images/etudes/en-US/firefox0703_cartecontis.png) )

or (http://www.xitimonitor.com/Images/etudes/en-US/firefox0703_cartepays.png)

I just wanted to point out that this kind of problem ("it works in firefox, but not in IE, why?") sends us back in the prehistoric age when no widely-accepted standard was present and people had to cope with every browser (mis-)implementation of HTML.

Those days are over. IMHO, the first and only wuestion to ask myself in front of such a problem is "is it coded correctly" and if the answer is "yes", then no further action is required. The user should be warned, though (as GS pointed out) : "use a decent browser".

I want to help, but I think this kind of problem should not exist any more and is a waste of time for both parties (the helper and the helped). It's a bit like someone complaining that their car couldn't get the "green sticker" (the one for "clean cars") because it is too old and pollutes too much : the only answer is "change your car".

Similarly, a website is "better viewed through clean glasses" ;-)

(http://www.edainworks.com/images/clean_glasses.gif)


Title: Re: javascript error: - not implemented
Post by: Esopo on June 14, 2007, 12:54:47 PM
On the client end, most users only care about having something that works. 

That was my point.

I agree with the motion to push for the adoption of compliant browsers, but this can't be done in every situation. In the corporate world IT departments are forcing users to quit IE, and on private not-for-profit sites and personal sites we can neglect IE to our leisure, but for the majority of the sites out there that matter (commercial ventures and public services)  developers just can't deny the very simple fact that most users will be browsing with IE, and these users can't understand and/or care about standards, bugs, etc.

For sites targeted at the general public in the real world, if a script doesn't work in IE, it doesn't work. Period. Better days may come, but for now that's the way it works.

I'm assuming that if the asker had been working on a script for a Firefox-run intranet, this question would have never been brought up.


BTW, VGR, that was a nice graphic.


Title: Re: javascript error: - not implemented
Post by: VGR on June 14, 2007, 11:23:06 PM
just to "elaborate" a bit, and despite it's not a "nice graphics" ;-) here is a snapshot on a narrower-audienced website :

Code:
European Experts Exchange (http://www.europeanexperts.org)
Total hors Bots = 1875 from 2007-06-12 13:08:30 to 2007-06-15 07:17:01
Browser        count %     Rem
MSIE 7.0 220     11.73 % \
MSIE 6.0         675    36.00 % |
MSIE<6             12     0.64 % / total IE = 48.37 %
Moz Firefox     665    35.47 % \
Moz Gecko         52     2.77 % |
Mozilla Others  182     9.71 % / total Mozilla = 47.95 %
Opera                27     1.44 %
Others              10     0.53 %
Unknown           32     1.71 %

Using an automotive analogy again, if a driver had its tachymeter (speedometer? in bad any-language) broken, he could not require the roadsigns to be modified just for him ;-)
the exact speed is accessible to normal cars following standards
His car is no longer adapted to modern roads
it's the same for browsers on the web


Title: Re: javascript error: - not implemented
Post by: COBOLdinosaur on June 15, 2007, 10:09:17 AM
I going to keep this short and simple. 

Users on the Web; not developers; not designers; and not  web publishers. 

What ever abortion the user put on their computer is their right.  If a significant group of them uses a particular browser then we have to support them.  FF got off the ground because enough of us used it to force web sites to support it.  IE will die as users learn there is a better way just as Netscrap died when IE4 came along asn was a much better browser;  but it did not happen overnight.

We have to support whatever the users use; or create a "cult of the perfect" like the MAC fanatics.



Title: Re: javascript error: - not implemented
Post by: VGR on June 16, 2007, 01:12:47 AM
[MODE FASCIST ON]
if we don't support IE quirks any more, we force the users to change for a real browser, and it's for their own Good.
It's a nice principle not to support imperfect things when better alternatives do exist.
[MODE FASCIST OFF]
;-)


Title: Re: javascript error: - not implemented
Post by: GrandSchtroumpf on June 16, 2007, 09:28:39 AM
It's exactly the opposite:  The visitor's rights are not respected when a site breaks in standards compliant browsers, not when it breaks in IE.

You write code that complies to some open standards and the visitor uses some software that complies to the same standards.
It's as simple as that.

Just like you should use ODF documents instead of M$ Office formats (DOC/XLS/PPT) for exchanging documents.
Even if Open Office handles the M$ Office files while M$ Office needs a plugin (http://odf-converter.sourceforge.net/) to handle the ODF files.

Many sites use Flash or Java and therefore force the visitors to install some particular software on their machine.
Requiring a standard compliant browser is a lot less fascist than that for two reasons:
1.  The visitor can choose between all the different standard compliant browsers that are available (gecko-based, khtml-based, opera).
2.  A lot of OS distributions come with standard compliant browsers (Linux, OSX), which means some users won't need to install anything on their system.

I strongly support and admire the sites that have the guts to require a decent browser (mostly scientific sites that need to include MathML in their pages).
As Esopo said, the only good reason to make special efforts to support IE is money.
BTW, anyone tried Safari for Windoze (http://www.apple.com/safari/)?


Title: Re: javascript error: - not implemented
Post by: Esopo on June 16, 2007, 12:10:15 PM
Perhaps I have a tainted view on the matter, since the people I have built websites for were all trying to make money. Anybody else ever experienced this? :)

We have to go with the market. You guys have very valid points that I happen to agree with, but the market is with IE. I code for IE for the same reason that the text is in English. I don't question the structure of English, I just  know it is the language that my users understand, hence my site has to be in English. Maybe someday I'll be writing sites in Esperanto, but not today.


Title: Re: javascript error: - not implemented
Post by: CrYpTiC_MauleR on June 16, 2007, 02:35:39 PM
Now don't anyone pounce on me, but can we please get this post back on topic. That way thepreacher can have his/her needed assistance regarding what portion of the code is causing the browser compatibility. Thank you =o)


Title: Re: javascript error: - not implemented
Post by: rdivilbiss on June 30, 2007, 07:41:02 PM
regarding:

Code:
function getExchrate(x, t, p, s, w)
{
if (!objRequest)
{
        getRequestobject();
}
 
var transcrncy = document.getElementById(t).value;
var paycrncy = p;
objRequest.onreadystatechange = handleHttpResponse2(x, s, w);
var params = '?param1=' + transcrncy + '&param2='+ paycrncy;
objRequest.open("GET", url2 + params, false);
objRequest.send(null);
}

given the error message, I suspect a problem with the value/object returned by getRequestobject(); such that when you execute objRequest.open(...) you get a "not implemented" error as getTequestobject did not return an XMLHTTP object.

Therefore, we would need to see the code for getRequestobject();.

On a more general note....the parameters to your functions may make sense to you at the time your wrote or modified this code, but they are of little or no value to somebody trying to debug.

It would seem you have some form fields (not shown) to get the transaction amount (withdraw amount?), transaction currency, the currency in which to make payment.  I'm guessing you are then making an AJAX call to get the exchange rate for the transaction currency and the currency in which to make payment.

However, not seeing your fields, and the fact you change the parameter names in each function, it is a bit confusing to follow.

In getExchrate() you have passed t and p which I guess to be the transaction currency field ID and the payout currency field ID, however you do not appear to get the payout currency field value.

Code:
var transcrncy = document.getElementById(t).value;
var paycrncy = p;

Shouldn't that be:

Code:
var transcrncy = document.getElementById(t).value;
var paycrncy = document.getElementById(p).value;
?

If that is true, then it follows that

Code:
var params = '?param1=' + transcrncy + '&param2='+ paycrncy;

will always be: "?param1=US&param2=" as paycrncy will have no value.

Also, you call url2 which is an undeclared variable or is a global not passed with the parameters.  You should be explicit and passs url2 or comment that it is a global.

Finally in that function you reference the handleHttpResponse2() function in which you pass x, s, w.  Again, I'm forced to guess, but it seems those parameters will be the field IDs of the eXchange rate field, the Subtotal field and the Withdraw amount field.

I guess this because the handleHttpResponse2() function sets x (fx) to the response value which appears to be the exchange rate.

Code:
document.getElementById(fx).value = arr[2];

Note, I don't know what arr[0] and arr[1] are, unless they are simply echoing back the transaction and payout currencies.

I don't see why you changed the values of the parameters in the definition of the handleHttpResponse2() function, as it only obscures what the original parameters were.

After getting the exchange rate, and putting its value into the exchange rate field, you call the calcSubtotal() function passing fx, subt, wd which were originally x, s, w and which are mapped to f, s, w in the calcSubtotal() function.

But there are some apparent problems in the calcSubtotal function.

First, you do not use f (which was originally x and passed from fx).

The line:
Code:
var exRate = document.getElementById(s).value;

seems to be getting the as yet not calculated subtotal value and using it for the exchange rate, when you should be doing

Code:
var exRate = document.getElementById(f).value;

Then,

Code:
document.getElementById(w).value = subTotal;

seems to be assigning the now incorrectly calculated subTotal to the withdraw field.  So that would seem to need to be:


Code:
document.getElementById(s).value = subTotal;

I would suggest you avoid the one letter field abbreviations, and use meaningful values in your parameters, such as:

getExchrate(xRateId, transAmtId, payoutAmtId, subTotalId, withdrawId) and keep the parameter names the same throughout your code.

They end with Id, because you are doing document.getElementById(xxx) on each of those parameters at some point.  If the field names make sense, such as exchangeRate, transAmt, payoutAmy, subTotal, withdrawAmt, then I would not pass the field ID's as parameters, but just hard code those perfectly understandable names into the document.getElementById(...) calls.  It is self documenting that those are field elements.

In any event, if after 19 days you haven't already discovered some of this out already, there is my anaylsis of the code.

Start with the getRequestobject(); to see if it is creating the object correctly for IE.

It should look something like this:

Code:
function getRequestobject() {
    if (window.ActiveXObject) {
try {
objRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try {
objRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
objRequest = null;
}
}
} else if (window.XMLHttpRequest) {
try {
objRequest = new XMLHttpRequest();
} catch(e) {
objRequest = null;
}
}

if (objRequest!=null) {
return objRequest;
} else {
return false;
}
}



 


Title: Re: javascript error: - not implemented
Post by: rdivilbiss on June 30, 2007, 09:58:50 PM
http://www.rodsdot.com/ee/ert1273.asp

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="author" content="Roderick Divilbiss">
<meta name="copyright" content="© 2005, 2006 Roderick Divilbiss">
<meta name="MSSmartTagsPreventParsing" content="TRUE">
<title>AJAX Exchange Rate</title>
<script type="text/javascript">
<!--
// global Object
var objRequest;

function getRequestObject() {
    if (window.ActiveXObject) {
        try {
           objRequest = new ActiveXObject("Msxml2.XMLHTTP");
        } catch(e) {
            try {
                objRequest = new ActiveXObject("Microsoft.XMLHTTP");
            } catch(e) {
                objRequest = null;
            }
        }
    } else if (window.XMLHttpRequest) {
        try {
            objRequest = new XMLHttpRequest();
        } catch(e) {
            objRequest = null;
        }
    }

    if (objRequest==null) {
        alert('Error');
        exit;
    }
}


function calcSubtotal(pExchangeRateId, pPayoutAmtId, pTransactionAmtId) {
    var transAmt = document.getElementById(pTransactionAmtId).value;
    var exRate = document.getElementById(pExchangeRateId).value;

    if ((exRate != "") && (transAmt != "")) {
        var payoutAmt = exRate * transAmt;
        document.getElementById(pPayoutAmtId).value = payoutAmt;
    }
}

function getExchrate(pExchangeRateId, pTransactionCurrencyId, pPayCurrencyId, pPayoutAmtId, pTransactionAmtId) {
    var transCurrency = document.getElementById(pTransactionCurrencyId).value;
    var payCurrency = document.getElementById(pPayCurrencyId).value;
    getRequestObject();
    if (objRequest) {
        objRequest.onreadystatechange = handleHttpResponse2;
        var params = '?tc=' + transCurrency + '&pc='+ payCurrency;
        objRequest.open("GET", 'http://www.rodsdot.com/ee/ert1273webService.asp' + params, true);
        objRequest.send(null);
    } else {
        document.getElementById(pPayoutAmtId).value = "ERROR";
        alert('Error: No HTTPResponse Object');
    }
}

function handleHttpResponse2() {
    if (objRequest.readyState == 4) {
        if (objRequest.status == 200) {
            var results2 = objRequest.responseText;
            objRequest=null;
            var arr=results2.split(',');
            document.getElementById('exchangeRate').value = arr[2];
            calcSubtotal('exchangeRate','payoutAmout','transactionAmount');
        }
    }
}
//-->
</script>
</head>

<body>
<form method="post" onsubmit="return false;">
  <p>Transaction Currency: <select size="1" name="transactionCurrency" id="transactionCurrency" onchange="getExchrate('exchangeRate','transactionCurrency','payoutCurrency','payoutAmout','transactionAmount');">
     <option value="EUR">EUR</option>
     <option value="USD" selected>USD</option>
     <option value="VND">VND</option>
   </select>&nbsp; Transaction Amount <input type="text" id="transactionAmount" name="transactionAmount" size="20" value="100" onchange="getExchrate('exchangeRate','transactionCurrency','payoutCurrency','payoutAmout','transactionAmount');"></p>
  <p>Exchange Rate: <input type="text" id="exchangeRate" name="exchangeRate" disabled size="20"></p>
  <p>Pay Currency: <select size="1" name="payoutCurrency" id="payoutCurrency" onchange="getExchrate('exchangeRate','transactionCurrency','payoutCurrency','payoutAmout','transactionAmount');">
     <option value="EUR">EUR</option>
     <option value="USD">USD</option>
     <option value="VND" selected>VND</option>
   </select> Pay Out Amount <input type="text" id="payoutAmout" name="payoutAmout" size="20" disabled value="0"></p>
  <p><input type="submit" name="bSubmit" value="Calculate" onclick="getExchrate('exchangeRate','transactionCurrency','payoutCurrency','payoutAmout','transactionAmount')"></p>
</form>
</body>

</html>


Title: Re: javascript error: - not implemented
Post by: rdivilbiss on June 30, 2007, 10:21:39 PM
Or alternatively....

http://www.rodsdot.com/ee/ert1273optionalFunction.asp


Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="author" content="Roderick Divilbiss">
<meta name="copyright" content="© 2005, 2006 Roderick Divilbiss">
<meta name="MSSmartTagsPreventParsing" content="TRUE">
<title>AJAX Exchange Rate</title>
<script type="text/javascript">
<!--
// global Object
var objRequest;

function getRequestObject() {
    if (window.ActiveXObject) {
        try {
           objRequest = new ActiveXObject("Msxml2.XMLHTTP");
        } catch(e) {
            try {
                objRequest = new ActiveXObject("Microsoft.XMLHTTP");
            } catch(e) {
                objRequest = null;
            }
        }
    } else if (window.XMLHttpRequest) {
        try {
            objRequest = new XMLHttpRequest();
        } catch(e) {
            objRequest = null;
        }
    }

    if (objRequest==null) {
        alert('Error');
        exit;
    }
}


function calcSubtotal(pExchangeRateId, pPayoutAmtId, pTransactionAmtId) {
    var transAmt = document.getElementById(pTransactionAmtId).value;
    var exRate = document.getElementById(pExchangeRateId).value;

    if ((exRate != "") && (transAmt != "")) {
        var payoutAmt = exRate * transAmt;
        document.getElementById(pPayoutAmtId).value = payoutAmt;
    }
}

function getExchrate(pExchangeRateId, pTransactionCurrencyId, pPayCurrencyId, pPayoutAmtId, pTransactionAmtId) {
    var transCurrency = document.getElementById(pTransactionCurrencyId).value;
    var payCurrency = document.getElementById(pPayCurrencyId).value;
    getRequestObject();
    if (objRequest) {
        objRequest.onreadystatechange = objRequest.onreadystatechange = function() {
                                        handleHttpResponse2(pExchangeRateId, pPayoutAmtId, pTransactionAmtId);
                                        };
        var params = '?tc=' + transCurrency + '&pc='+ payCurrency;
        objRequest.open("GET", 'http://www.rodsdot.com/ee/ert1273webService.asp' + params, true);
        objRequest.send(null);
    } else {
        document.getElementById(pPayoutAmtId).value = "ERROR";
        alert('Error: No HTTPResponse Object');
    }
}

function handleHttpResponse2(pExchangeRateId, pPayoutAmtId, pTransactionAmtId) {
    if (objRequest.readyState == 4) {
        if (objRequest.status == 200) {
            var results2 = objRequest.responseText;
            objRequest=null;
            var arr=results2.split(',');
            document.getElementById(pExchangeRateId).value = arr[2];
            calcSubtotal(pExchangeRateId, pPayoutAmtId, pTransactionAmtId);
        }
    }
}
//-->
</script>
</head>

<body>
<form method="post" onsubmit="return false;">
  <p>Transaction Currency: <select size="1" name="transactionCurrency" id="transactionCurrency" onchange="getExchrate('exchangeRate','transactionCurrency','payoutCurrency','payoutAmout','transactionAmount');">
     <option value="EUR">EUR</option>
     <option value="USD" selected>USD</option>
     <option value="VND">VND</option>
   </select>&nbsp; Transaction Amount <input type="text" id="transactionAmount" name="transactionAmount" size="20" value="100" onchange="getExchrate('exchangeRate','transactionCurrency','payoutCurrency','payoutAmout','transactionAmount');"></p>
  <p>Exchange Rate: <input type="text" id="exchangeRate" name="exchangeRate" disabled size="20"></p>
  <p>Pay Currency: <select size="1" name="payoutCurrency" id="payoutCurrency" onchange="getExchrate('exchangeRate','transactionCurrency','payoutCurrency','payoutAmout','transactionAmount');">
     <option value="EUR">EUR</option>
     <option value="USD">USD</option>
     <option value="VND" selected>VND</option>
   </select> Pay Out Amount <input type="text" id="payoutAmout" name="payoutAmout" size="20" disabled value="0"></p>
  <p><input type="submit" name="bSubmit" value="Calculate" onclick="getExchrate('exchangeRate','transactionCurrency','payoutCurrency','payoutAmout','transactionAmount')"></p>
</form>
</body>

</html>


Title: Re: javascript error: - not implemented
Post by: thepreacher on July 23, 2007, 06:44:17 PM
Sorry guys I traveled for a bit hence the silence. Will soon try your suggestions and report.

Thnx