Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Closed Thread
Why does this code not work in firefox
Old 03-06-2009, 11:18 AM Why does this code not work in firefox
Novice Talker

Posts: 12
Trades: 0
Hi Guys,

im very new to Java script. I have been put in charge to change the look and feel of our companies payment system. I have changed so far everything. Only one page gives me an error in firefox. The Code is very old and the developer is not reachable anymore. Can someone give me some hints where and what i have to change to get this working in firefox.

I have checked the error console and get following error
document.all is not a function for example

Many thanks upfront

Code:
<SCRIPT Lang="Javascript">

function isNumeric(str)
{

   if (str.length < 1) {
     return false
   }

  for (var i=0; i < str.length; i++)
        {
    var ch = str.substring(i, i+1)
    if(ch != "." && ch < "0" || ch > "9")
                {
      return false
    }
  }
  return true
}    

   function submitPayment()
   {
      var bValidated = true;
      var strName = '';
      var strInput = '';
      
      document.all('submitButton').disabled = true; 
      strInput = (paymentForm('Amount').value);    
      
      while (strInput.indexOf(' ') >= 0)
      {
        //alert('while = ' + strInput.indexOf(' '));
        strInput = strInput.replace(' ','');
        //alert('str = ' + strInput);
      }
      //alert('str = ' + strInput);
      paymentForm('Amount').value = strInput
      if (isNumeric(strInput) == false)
      {
         bValidated = false;
         strName = ('Amount');
         document.all.Amount.focus();
      }
      
     
      strInput = paymentForm('CCNo').value;
      while (strInput.indexOf(' ') >= 0)
      {
        strInput = strInput.replace(' ','');
      }
      paymentForm('CCNo').value = strInput
      if (isNumeric(strInput) == false)
      {
         bValidated = false;
         strName = 'Credit Card Number';
         document.all.CCNo.focus();
      }
      
      strInput = paymentForm('ContactNo').value;    
      while (strInput.indexOf(' ') >= 0)
      {
        strInput = strInput.replace(' ','');
      }
      paymentForm('ContactNo').value = strInput
      if (isNumeric(strInput) == false)
      {
         bValidated = false;
         strName = 'Buyer Tel. No.';
         document.all.ContactNo.focus();
      }
        
      if (bValidated == true)
      {
         paymentForm.submit();
      }
      else
      {
         document.all('submitButton').disabled = false; 
         alert('Please enter valid data into ' + strName + ' field.')
      }
      
            
   }
</SCRIPT>

Last edited by wappoint; 03-06-2009 at 11:23 AM..
wappoint is offline
View Public Profile
 
 
Register now for full access!
Old 03-06-2009, 11:23 AM Re: Why does this code not work in firefox
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
And the error is?

but for a start

<SCRIPT Lang="Javascript">
should be

<script type="text/javascript">
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
View Public Profile Visit chrishirst's homepage!
 
Old 03-07-2009, 03:27 AM Re: Why does this code not work in firefox
Novice Talker

Posts: 12
Trades: 0
Hi Chrishirst

Thanks for the tip. Have changed that, but still getting the same error.

Any other tips?

Thanks
wappoint is offline
View Public Profile
 
Old 03-07-2009, 05:17 AM Re: Why does this code not work in firefox
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
document.all is NOT a function that is implemented in all browsers. It is an abysmal, non-standard (IE4) method of DOM coding that should have died out long ago.

Use document.getElementById(elementName) instead
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
View Public Profile Visit chrishirst's homepage!
 
Old 03-07-2009, 08:05 AM Re: Why does this code not work in firefox
Novice Talker

Posts: 12
Trades: 0
Hi,

thanks for the info. I have changed it to the above mentioned. Now it gives me a new error.

Error code in console paymentForm is not defined and it refers to the code line

strInput = (paymentForm('Amount').value);

Any more tips? Really appreciate your help chrishirst ;-)
wappoint is offline
View Public Profile
 
Old 03-07-2009, 08:27 AM Re: Why does this code not work in firefox
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
document.formname.elementname.value
or
document.forms['formName'].elements['elementName'].value
or
document.getElementById('elementID').value
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
View Public Profile Visit chrishirst's homepage!
 
Old 03-07-2009, 10:35 AM Re: Why does this code not work in firefox
Novice Talker

Posts: 12
Trades: 0
Hi Chrishirst,

thanks again for the next info. Still not working. Now it even does not work in IE anymore ;-(.

Will you be able to have a look at it when i send you the file? Im even willing to pay you for your duties via Paypal.

Thanks
wappoint is offline
View Public Profile
 
Old 03-07-2009, 10:57 AM Re: Why does this code not work in firefox
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
just post a URI for the page, and if I'm not about one of the js coders will pick it up.

leave off the http://www bit to prevent auto linking or uncheck the "Automatically parse links in text" box below the reply box (not the quick reply one)
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
View Public Profile Visit chrishirst's homepage!
 
Old 03-07-2009, 11:40 AM Re: Why does this code not work in firefox
Novice Talker

Posts: 12
Trades: 0
Hi Chrishirst,

I would gladly post the url, but, in order to get to that form/page you need to be logged in. Unfortunately I won't be able to post the login details here, even though it's just a demo user to test on.

Alternatively I can upload the file itself and it can be tested locally via ISS.
wappoint is offline
View Public Profile
 
Old 03-07-2009, 01:00 PM Re: Why does this code not work in firefox
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Problem has been solved, javascript syntax errors was the issues.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
View Public Profile Visit chrishirst's homepage!
 
Closed Thread     « Reply to Why does this code not work in firefox
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.74036 seconds with 12 queries