未捕获类型错误:对象不是一个函数,按钮内的形式
我有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 code>,它抛出的消息的异常:
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".