Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2005
    Posts
    93

    * JAVASCRIPT - Doesnt Work in FireFox

    I have some Javascript that takes the input from some textboxes and then puts them all into a sentance automatically. It works perfectly in IE but not with FireFox... does anyone know how to make it work with both browsers?

    HTML Code:
    <script type="text/javascript">
    function Text_Change() {
      var TxtFName = document.getElementById("TxtFName");
      var TxtSName = document.getElementById("TxtSName");
      var TxtAge = document.getElementById("TxtAge");
      var TxtLoc = document.getElementById("TxtLoc");
    
      var SpnDisp = document.getElementById("SpnDisp");
    
      var FName = TxtFName.value == "" ? "?" : TxtFName.value;
      var SName = TxtSName.value == "" ? "?" : TxtSName.value;
      var Age = TxtAge.value == "" ? "?" : TxtAge.value;
      var Loc = TxtLoc.value == "" ? "?" : TxtLoc.value;
    
      SpnDisp.innerHTML =
        "Hello " + FName + " " + SName + ", " +
        "you are " + Age + " years old and " +
        "at the moment you live in " + Loc;
    }
    </script>
    
    <body onload="Text_Change()">
    
    <div><input type="text" id="TxtFName" onchange="Text_Change()" /></div>
    <div><input type="text" id="TxtSName" onchange="Text_Change()" /></div>
    <div><input type="text" id="TxtAge" onchange="Text_Change()" /></div>
    <div><input type="text" id="TxtLoc" onchange="Text_Change()" /></div>
    
    <div><span id="SpnDisp"></span></div>
    Turn My Text - íspuǝıɹɟ ʞooqǝɔɐɟ ɹnoʎ ǝzɐɯɐ puɐ ǝsnɟuoɔ

    Computer Game Cheats & Codes

  2. #2
    Join Date
    Aug 2002
    Location
    Canada
    Posts
    665
    eyeballing it just now, I would have predicted that it work in FF and not IE! With IE6, getElementById looked for a name attribute instead of id. Using IE7? You'd have to duplicate each id=X with name=X to maintain compatability with older browsers. I digress.. get this extension in firefox:
    https://addons.mozilla.org/firefox/1843/

    It will let you know where you are having problems precisely. Great extension!
    circlical - hosting software development
    forums * blog

  3. #3
    Join Date
    Mar 2005
    Posts
    93
    Im using IE6

    I posted on another forum and they found the answer, it wasnt working in IE because I needed to an <form></form> around the fields.

    I will be downloading that extension though - thank you
    Turn My Text - íspuǝıɹɟ ʞooqǝɔɐɟ ɹnoʎ ǝzɐɯɐ puɐ ǝsnɟuoɔ

    Computer Game Cheats & Codes

Posting Permissions

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