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 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Having problems with "onLoad"?

    I have no idea why the following code does not work in Explorer. It works okay in Firefox. In Explorer, the text box is blank. The onload function seems to not be executed since it is not displaying the value.

    Any suggestions?

    Code below:
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script language="JavaScript">
    function fnLoadSetup()
    {
    document.userForm.sInit_Text.value = "Text Here";
    }
    </script>
    </head>
    <body bgcolor="#CCCCCC" text="#000000" onLoad="fnLoadSetup()">
    <form name="userForm" method="post" action="">
    <input type="text" name="sInit_Text" readonly>
    </form>
    </body>
    </html>

  • #2
    Senior Coder
    Join Date
    Dec 2004
    Location
    Essex, UK
    Posts
    2,636
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, firstly <script language="JavaScript"> is not valid. <script type="text/javascript"> Should replace it.

    You could give the text box an ID -

    <input type="text" name="sInit_Text" id="sInit_Text" readonly>

    And see if that helps?

    Or then try replacing the javascript with -

    document.getElementById("sInit_Text").value="Text Here";

  • #3
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Still not working

    That didn't work. This code works okay when I run it through my webserver in an asp file however it doesn't work as an html file.

  • #4
    Senior Coder
    Join Date
    Dec 2004
    Location
    Essex, UK
    Posts
    2,636
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well your original HTML works fine for me in IE... are you sure you have Javascript enabled (don't mean to sound patronising)?

    You could set the original value without Javascript like so if that helps -

    <input type="text" value="Text Here" name="sInit_Text" readonly>

  • #5
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript was not enabled

    Thanks for your help. It turns out my javascript was not enabled (well actually the java settings was set at "Medium Safety", and I changed it to "Low Safety" to make it work).

    I have between running the same files as "asp" files, and there is tons of javascript that is executed since these files upload data, and I use javascript to display the data. I converted one of the asp files to html and deleted the upload commands and hardcoded values into the javascript. I am surprised that the html files did not execute the javascript functions since there were no problems executing them when the file was an "asp" file.

    It is working now. Thanks again for your help!!!

  • #6
    Senior Coder
    Join Date
    Dec 2004
    Location
    Essex, UK
    Posts
    2,636
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No prob, are you running these offline to test by the way? Because instead of changing the security level you could try unticking the box Tools>Internet Options>Advanced>Security>Allow active content to run in files on My Computer.


  •  

    Posting Permissions

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