无法在IE中访问表单元素,因为它'未定义'。在FF和Chrome中工作正常 [英] Can't access form element in IE because it 'is undefined'. Works ok in FF and Chrome

查看:329
本文介绍了无法在IE中访问表单元素,因为它'未定义'。在FF和Chrome中工作正常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很奇怪,因为我只在IE中得到1个错误:'sTime is undefined'。 sTime是我的形式中许多输入元素之一的ID。一切工作正常在Chrome和FF。以下是代码的链接:

It's strange because I only get 1 error in IE: 'sTime is undefined'. sTime is the ID of one of the many input elements in my form. Everything works fine in Chrome and FF. Here's a link to the code:

http: //la.truxmap.com/sched.html

和格式html:

<form id="addNewTruck" class='updateschedule' action="javascript:sub(sTime.value, eTime.value, lat.value, lng.value, street.value);"> 

    <b style="color:green;">Opening at: </b> 
        <input id="sTime" name="sTime" title="Opening time" value="Click to set opening time" class="datetimepicker"/> 

    <b style="color:red;">Closing at: </b> 
        <input id="eTime" name= "eTime" title="Closing time" value="Click to set closing time" class="datetimepicker"/> 

    <b style="color:blue;">Address: </b> 
        <input type='text' name='street' id='street' class='text street' autocomplete='off'/> 
        <input id='submit' class='submit' style="cursor: pointer; cursor: hand;" type="submit" value='Add new stop'/> 
    <div id='suggests' class='auto_complete' style='display:none'></div> 
        <input type='hidden' name='lat' id='lat'/> 
        <input type='hidden' name='lng' id='lng'/> 
        <input type='hidden' value='CA' name='state' id='state' class='text state' /> 

感谢您的帮助! / p>

Thanks for your help!

推荐答案


  • 尝试将JavaScript放在 onsubmit 事件而不是动作

    在JS中不明确地填写表单元素,例如使用 this.elements.sTime 。可能是文档中其他位置使用的元素名称。

    Address the form elements less ambiguously in the JS, e.g. using this.elements.sTime. It could be that the element name is used elsewhere in the document.

    这篇关于无法在IE中访问表单元素,因为它'未定义'。在FF和Chrome中工作正常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆