未捕获类型错误:对象不是一个函数,按钮内的形式 [英] Uncaught TypeError: object is not a function, button inside form

查看:492
本文介绍了未捕获类型错误:对象不是一个函数,按钮内的形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有code的片断在我的jsp页面:

I have the following snippet of code in my jsp page:

<form name="programarRutasForm" method="post" action="/SGT_Galp_web/programarRutas.do">   
     <table>
        <tr>
          <td>
            <input type="button" name="insereVuelta" value="Insere Vuelta" onclick="insereVuelta()" id="insereVuelta">
          </td>
          <td>
            <input type="submit" name="criaRuta" value="Cria Ruta" id="criaRuta">
          </td>
        </tr>
     </table>
     ...

当我点击按钮 insereVuelta ,它抛出的消息的异常:

When I click the button insereVuelta, it throws an exception with the message:

未捕获类型错误:对象不是一个函数

但是,如果我把按钮的形式外面工作正常。怎么会这样呢?我真的需要把靠近按钮的形式里面的提交按钮。

But if I put the button outside the form it works normally. How is this happening? I really need to put the button near the submit button inside the form.

推荐答案

我相信从具有相同的名称作为按钮本身的功能问题造成的。我有同样的问题,并改变固定它的按钮的名称。它看起来像更改按钮的名称定为你,为好​​。

I believe the problem stems from the function having the same name as the button itself. I had the same problem and changing the name of the button fixed it. It looks like changing the name of your button fixed it for you, as well.

猜想:

我猜想,当名称是相同的,跨preTER试图调用按钮本身,而不是功能。因为按钮是不是一个函数,它引发错误。

I would guess that when the names are the same, the interpreter is trying to call the button itself, rather than the function. Because the button isn't a function, it throws the error.

我没有对为什么它为你工作的形式以外时的解释,虽然。也许当一个按钮的形式外,跨preTER不会自动连线它作为以同样的方式可访问的对象,或者它会通过一个父。

I don't have an explanation for why it worked for you when outside the form, though. Perhaps when a button is outside the form, the interpreter doesn't automatically wire it up as an accessible object in the same way, or maybe it would have to be accessed via a "parent".

这篇关于未捕获类型错误:对象不是一个函数,按钮内的形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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