Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

silly javasript question - not working in firefox

Explorer ,
Aug 04, 2009 Aug 04, 2009

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!

842
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Aug 04, 2009 Aug 04, 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 05, 2009 Aug 05, 2009
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources