Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool Simple Javascript not working in firefox.

    Its been some while since I used javascript and even when I used to use it I was wasn't very good at it.

    Can you tell me what is wrong with this script and how to get it working in firefox, there is more to the code but it manly these if statements repeating it self, I am think the code isn't valid or something.


    Code:
    function run() {
    document.form1.RunnungT.value = "0"
    var Total = 0;
    document.all.testtext.innerHTML = "";
    
    document.all.testtext.innerHTML = "<ul><b><u>Items Selected</u></b>";
    
    
    if (document.form1.Thredbo.checked)
      {
      		if (document.form1.J8.checked)
            {
    		Total = Total + 469;
    		document.form1.RunnungT.value = Total;
    		document.all.testtext.innerHTML = document.all.testtext.innerHTML + "<li>Thredbo July 8th - 11th (Four days)</li>";
    		}
      		if (document.form1.J86.checked)
            {
    		Total = Total + 669;
    		document.form1.RunnungT.value = Total;
    		document.all.testtext.innerHTML = document.all.testtext.innerHTML + "<li>Thredbo June 8th - 13th (Six days)</li>";
    		}
    
      }
       
      document.all.testtext.innerHTML = document.all.testtext.innerHTML + "</ul>"; 
    }
    </script>

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Get rid of the document.all calls that were for Internet Explorer 4 and replace them with document.getElementById() which works in all browsers that have been released in the last 10 years including IE5+, Firefox 0.1+ etc
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,522
    Thanks
    3
    Thanked 508 Times in 495 Posts
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    </head>
    
    <body>
    
    <div id="testtext" ></div>
    <script  type="text/javascript">
    /*<![CDATA[*/
    document.getElementById('testtext').innerHTML='use  document.getElementById';
    /*]]>*/
    </script>
    </body>
    
    </html>
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •