By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,921 Members | 1,466 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,921 IT Pros & Developers. It's quick & easy.

Firefox Javascript error (maybe getElementByID)

P: 4
Hello,

I'm really bad at javascript but I managed to get the code below to work in IE but firefox gives this error...

Error: document.getElementById.formall is undefined

Basically use the script to update the display to the user depending on what they choose (qty, options, shipping etc.)

I'm sure it's simple but I could really use a hand.
Thanks!!

Expand|Select|Wrap|Line Numbers
  1. <SCRIPT language="JavaScript">
  2. function update_UsernameText()
  3. {
  4.     document.getElementById('UsernameTXT').innerHTML = document.getElementById.formall.smrtEmail.value;
  5. }
  6. function Calculate()
  7. {
  8.    // calculate each line total
  9.  
  10.     if (document.formall.extrQTY.value == 1){
  11.  
  12. document.formall.extrQTY2.value = ((document.formall.extrQTY.value) * 4).toFixed(2);
  13.     document.formall.extrTotalQTY.value = (parseFloat(document.formall.extrQTY.value) + 1);
  14.  
  15.     }else{
  16.  
  17.     formall.extrQTY2.value = ((formall.extrQTY.value) * 2.75).toFixed(2);
  18.     document.getElementById('extrQTY2A').innerHTML = formall.extrQTY2.value;
  19.     formall.extrTotalQTY.value = (parseFloat(formall.extrQTY.value) + 1);
  20.     }
  21.  
  22.     //Test Copy radio values
  23.     if(formall.testdisc_0.checked==true){
  24.     formall.extrQTY6.value = (10).toFixed(2);
  25.     document.getElementById('extrQTY6A').innerHTML = formall.extrQTY6.value;
  26.     }else{
  27.     formall.extrQTY6.value = (0).toFixed(2);
  28.     document.getElementById('extrQTY6A').innerHTML = formall.extrQTY6.value;
  29.     }
  30.  
  31.     //Paper type
  32.     if(formall.paperType_0.checked==true){
  33.     formall.extrQTY4.value = ((formall.extrTotalQTY.value) * (0.00)).toFixed(2);
  34.     document.getElementById('extrQTY4A').innerHTML = formall.extrQTY4.value;
  35.     }else{
  36.     formall.extrQTY4.value = ((formall.extrTotalQTY.value) * (0.10)).toFixed(2);
  37.     document.getElementById('extrQTY4A').innerHTML = formall.extrQTY4.value;
  38.     }
  39.  
  40.     //Disc Face type
  41.     if(formall.discFaceType_0.checked==true){
  42.     formall.extrQTY5.value = ((formall.extrTotalQTY.value) * (0.00)).toFixed(2);
  43.     document.getElementById('extrQTY5A').innerHTML = formall.extrQTY5.value;
  44.     }else{
  45.     formall.extrQTY5.value = ((formall.extrTotalQTY.value) * (0.34)).toFixed(2);
  46.     document.getElementById('extrQTY5A').innerHTML = formall.extrQTY5.value;
  47.     }
  48.  
  49.    //frmOptions1.extrQTY6.value = frmOptions1.testdisc_0.value;
  50.    formall.extrQTY3.value = ((parseFloat(formall.shrinkQTY.value))*(0.29)).toFixed(2); 
  51.     document.getElementById('extrQTY3A').innerHTML = formall.extrQTY3.value;     
  52.    formall.Subtotal.value = ((parseFloat(formall.extrQTY2.value)) + (parseFloat(formall.extrQTY3.value)) + (parseFloat(formall.extrQTY4.value)) + (parseFloat(formall.extrQTY5.value))    + (parseFloat(formall.extrQTY6.value))).toFixed(2);
  53.  
  54.     formall.Subtotal3.value = ((parseFloat(formall.Subtotal.value)) + (parseFloat(formall.Subtotal2.value))).toFixed(2);
  55.     document.getElementById('SubtotalA').innerHTML = formall.Subtotal.value;
  56.     document.getElementById('Subtotal2A').innerHTML = formall.Subtotal2.value;
  57.     document.getElementById('Subtotal3A').innerHTML = formall.Subtotal3.value;
  58. }
  59.  
  60. </SCRIPT>
May 16 '09 #1
Share this Question
Share on Google+
1 Reply


gits
Expert Mod 5K+
P: 5,329
this:

Expand|Select|Wrap|Line Numbers
  1. document.getElementById.formall;
  2.  
shouldn't work ... don't know really why the crappy IE does ... and whether it does it correctly but its completely wrong it must be:

Expand|Select|Wrap|Line Numbers
  1. document.getElementById(formall);
and formall needs to be a valid id otherwise the method should return null.

kind regards
May 17 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.