在javascript中,我如何引用this.form.checkbox [5] .checked? [英] In javascript how do I refer to this.form.checkbox[5].checked?

查看:58
本文介绍了在javascript中,我如何引用this.form.checkbox [5] .checked?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一系列复选框和输入type ="text"区域,其中当文本区域中的值更改时,我需要将复选框的状态设置为true.很简单.我已成功完成此操作:

I have a series of checkboxes and input type="text" areas, wherein I need to have the state of the checkbox set to true when the value in the text area changes. Simple enough. I've done this successfully:

<input name="fixed" type="checkbox">
<input name="stuff" type="text" onchange="this.form.fixed.checked=true">

哪个工作正常.您必须编辑该字段,然后单击它,但这对我来说很合适:

Which works fine. You have to edit the field then click out of it, but that is fine for my needs:

...但是当我切换到此时:

...but when I switch to this:

<input name="fixed[0]" type="checkbox">
<input name="stuff" type="text" onchange="this.form.fixed[0].checked=true">
<input name="fixed[1]" type="checkbox">
<input name="stuff" type="text" onchange="this.form.fixed[1].checked=true">

编辑时,我的复选框没有任何变化:

I get no change to my checkboxes when I edit:

恐怕,我唯一的JavaScript专有技术来自谷歌搜索这类事情.有没有人比山上的Google甲骨文商店提供更好的信息了?

My only javascript know-how comes from googling this sort of thing, I'm afraid. Anyone have any better info on this than the Oracle of Google on The Mountain has in store?

谢谢...

推荐答案

从点表示法切换到方括号表示法!

Switch from dot notation to bracket notation!

this.form['fixed[0]'].checked

这篇关于在javascript中,我如何引用this.form.checkbox [5] .checked?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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