有办法吗。 TIA Frank Hi, im using Struts with nested tags for form validation.So I end up with form elements named like this risikenManuell[0].praemieNeurisikenManuell[1].praemieNeu.... I would like to do a calculation on the input valuesusing javascript but I don''t know how toaddress the fields. With alert(document.vertragEditForm.risikenManuell[0].praemieNeu);I get the error, that this element is null or not an object. Is there a way to do it. TIAFrank推荐答案 Frank Stephan说: Frank Stephan said: 带警报(document.vertragEditForm.risikenManuell [0] .praemieNeu); 我收到错误,这个元素是null或不是对象。 有没有办法做到这一点。With alert(document.vertragEditForm.risikenManuell[0].praemieNeu);I get the error, that this element is null or not an object.Is there a way to do it. http://www.jibbering.com/faq/#FAQ4_25 http://www.jibbering.com/faq/#FAQ4_25 fr *********** @ gmx.de (Frank Stephan)写道: fr***********@gmx.de (Frank Stephan) writes: 所以我最终得到了这样的表单元素 risikenManuell [0] .praemieNeu ....带警报(document.vertragEditForm.risikenManuell) [0] .praemieNeu); 我得到错误,这个元素是null或者不是对象。 有没有办法做到这一点。 So I end up with form elements named like this risikenManuell[0].praemieNeu.... With alert(document.vertragEditForm.risikenManuell[0].praemieNeu); I get the error, that this element is null or not an object. Is there a way to do it. 是的,它甚至在FAQ中: < URL:http://jibbering.com/faq/#FAQ4_25> 在你的情况下: document.forms [''vertragEditForm'']。elements [''riskenManuell [0] .praemieNeu''] / L - Lasse Reichstein Nielsen - lr*@hotpop.com DHTML死亡颜色:< URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html> ''Fait没有判断的人只会降低精神上的神性。'' Yes, and it''s even in the FAQ:<URL:http://jibbering.com/faq/#FAQ4_25>In your case:document.forms[''vertragEditForm''].elements[''riskenManuell[0].praemieNeu''] /L--Lasse Reichstein Nielsen - lr*@hotpop.comDHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>''Faith without judgement merely degrades the spirit divine.'' 2004年1月7日09:05:25 -0800,Frank Stephan< fr ******* ****@gmx.de>写道: On 7 Jan 2004 09:05:25 -0800, Frank Stephan <fr***********@gmx.de> wrote: 我使用Struts和嵌套标签进行表单验证。所以我最终得到了像这样的表单元素 risikenManuell [0] .praemieNeu risikenManuell [1] .praemieNeu ... 你的意思是:< INPUT .. .name =" risikenManuell [0]"> 我想用输入值计算使用javascript但是我不知道如何解决字段。 使用alert(document.vertragEditForm.risikenManuell [0] .praemieNeu); 样式注释:你应该使用完全限定的引用来帮助 防止名称冲突。也就是说,window.alert(...),而不是警告(...)。 我得到错误,该元素为null或不是对象。 Hi, im using Struts with nested tags for form validation. So I end up with form elements named like this risikenManuell[0].praemieNeu risikenManuell[1].praemieNeu ...You mean like: <INPUT ... name="risikenManuell[0]"> I would like to do a calculation on the input values using javascript but I don''t know how to address the fields. With alert(document.vertragEditForm.risikenManuell[0].praemieNeu);An style comment: you should use fully-qualified references to helpprevent name collisions. That is, window.alert(...), not alert(...). I get the error, that this element is null or not an object. 上面你的行的问题是括号([])是运算符, 用于下标数组。 JavaScript引擎会将上面的 risikenManuell [0]解释为''评估数组的第一个元素, risikenManuell''。要解决这个问题以及其他跨浏览器问题,请使用 集合语法: document.forms [''form_name'']。elements [ ''control_name'']。method_or_property 例如, document.forms [''vertragEditForm'']。elements ['' risikenManuell [0]'']。praemieNeu Mike - Michael Winter M.******@blueyonder.co.inva 盖子(替换.invalid与.uk回复) The problem with your line above is that brackets ([ ]) are operators,used to subscript arrays. The JavaScript engine will interpret therisikenManuell[0] above as ''evaluate the first element of the array,risikenManuell''. To get around this, and other cross-browser problems, usethe collections syntax: document.forms[''form_name''].elements[''control_name''].method_or_property For example, document.forms[''vertragEditForm''].elements[''risikenManuell[0]''].praemieNeu Mike --Michael Winter M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply) 这篇关于使用数组寻址表单元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-10 19:14