English 中文(简体)
处理Javascript的Mutlidimensional室
原标题:processing a Mutlidimensional HTML array in Javascript

下面的超文本已经以黑体模版格式分发:

<td><input type="checkbox" name="confirmRelated[{$relatedIP.ipInt}_{$relatedIP.patternID}][confirm]" /></td>
<td><input type="hidden" name="confirmRelated[{$relatedIP.ipInt}_{$relatedIP.patternID}][ipInt]" value="{$relatedIP.ipInt}">{$relatedIP.robotIP}</td>
<td><input type="hidden" name="confirmRelated[{$relatedIP.ipInt}_{$relatedIP.patternID}][patternID]" value="{$relatedIP.patternID}">{$relatedIP.pattern}</td>

我试图用javascript进入田地,但我迄今甚至连基本面都感到不安。 谁能帮助?

var boxes = document.getElementsByName( confirmRelated );
alert(boxes.length);

此时此刻,这显然是错误的。 I m 试图通过所有这些检查箱,检查“公司”检查箱。

感谢任何帮助。

最佳回答

您可以通过<代码>文件.getElementByName(查阅。 应努力:

var boxes = document.getElementsByTagName( input );
for(i = 0; i < boxes.length; i++){
    if(boxes[i].name ==  confirmRelated  && boxes[i].type ==  checkbox ){
        boxes[i].checked =  checked ;
    }
}

这将使所有投入都与类型检查箱相核对。

www.un.org/Depts/DGACM/index_spanish.htm 采用像你这样的框架,可以大大便利:

$$( input[name=^"confirmRelated"] ).each(function(elm){
    if(elm.type ==  checkbox ) elm.checked =  checked ;
});
问题回答

That returns 0 at the moment, which is obviously wrong.

页: 1 没有任何内容被确认为姓名。

你们应该通过自己的阵列(javascript don t notes this as range)来管理所有投入领域(目标要素ByTagName(投入))并检查贵方的傲慢元素名称是否从确认相关开始(如果是的话,你想要做什么)。

您可使用JQuery 选任人

$("input[name^= confirmRelated ]")

由于所有投入名称都是用确认书开始的,模板发动机在其中增加了一些固定员额。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签