Skip to main content
Inspiring
August 4, 2009
Question

silly javasript question - not working in firefox

  • August 4, 2009
  • 1 reply
  • 887 views

I have a simple javascript that works in IE, but just found out it does not work in firefox

It is just a dropdown form field that then populates a textbox with the value of the dropdown box

function displaytime() {
document.Form1.timedisplay.value = document.Form1.Time.options.value;
return;
}

In IE it works, but in Firefox, the timedisplay textbox displays as 'undefined'

Any ideas of how ot define these variables for firefox

thanks!

    This topic has been closed for replies.

    1 reply

    Inspiring
    August 5, 2009

    Hi,

    Try like this,

    <script language="javascript">
        function displaytime()
        {
            var timeObj=document.getElementById("Time");
            document.Form1.timedisplay.value = timeObj.value;
            return;
        }
    </script>

    <form name="Form1">
        <input type="text" name="timedisplay" value="" /><br>
        <select id="Time" name="Time" onChange="displaytime();">
            <option value="One">1</One>
            <option value="Two">2</One>
            <option value="Three">3</One>
            <option value="Four">4</One>
            <option value="Five">5</One>
        </select>
    </form>

    HTH

    Inspiring
    August 5, 2009

    thanks for the response - it would probably work.

    I ended up using this:

    function displaytime() {
    document.forms['Form1'].elements['timedisplay'].value = document.forms['Form1'].elements['Time'].value;
    return;
    }

    just changing the syntax slightly got firefox to work

    thanks