[Appendix D] D.3 Form Values and String Conversion
Author: David Flanagan
Date: Fri Aug 29 10:43:51 1997

#

| Appendix D JavaScript Incompatibilities in Internet Explorer 3.0 |

## D.3 Form Values and String Conversion

The JavaScript interpreter in Internet Explorer 3.0 does not always convert objects to strings when they are used in a "string context". This happens most notably when objects are assigned to the `value` field of form elements. To make this work correctly, you have to explicitly convert the object to a string, either by invoking its `toString()` method or by adding the empty string to it. To display the date and time in a form, for example, you'd have to use code like this:

    today = new Date();
    document.forms[0].dateandtime.value = today.toString()

or like this:

    today = new Date();
    document.forms[0].dateandtime.value = today + "";

If you encounter this conversion problem in other contexts, the workaround is the same.

Case Sensitivity |  | Object Model Differences