表格的字段编号 [英] form's field number
问题描述
表单的输入字段。如何查看此字段的编号?我的意思是
订单号,就像
document.forms [formnumber] .elements [elementNumber]中的变量elementNumber一样?是否可以在没有循环的情况下检查
并比较每个循环中的某些属性?
祝你好运,
ABS
Input field of the form. How to check which number this field has ? I mean
the order number, like variable elementNumber in
document.forms[formnumber].elements[elementNumber] ? Is it possible to check
without looping and comparing some attributes in every loop ?
Best regards,
ABS
推荐答案
abs写道:
表单的输入字段。如何查看此字段的编号?我
表示订单号,就像
document.forms [formnumber] .elements [elementNumber]中的变量elementNumber一样?是否可以在没有循环的情况下检查
并比较每个循环中的一些属性?
最好的问候,
ABS
Input field of the form. How to check which number this field has ? I mean the order number, like variable elementNumber in
document.forms[formnumber].elements[elementNumber] ? Is it possible to check without looping and comparing some attributes in every loop ?
Best regards,
ABS
为什么需要这个?只是好奇。没有
运行时循环的唯一方法是使用脚本onload在每个元素上设置索引属性
:
window.onload = function()
{
var f,els,el,i = 0,j;
while(f = document.forms [i ++])
{
els = f.elements;
j = 0;
while(el = els [j])
el.index = j ++;
}
}
然后作为elementObj.index访问。
Why do you need this? Just curious. The only way afaik to do it without
run-time looping is to use a script onload that sets an index property
on each element:
window.onload = function()
{
var f, els, el, i = 0, j;
while (f = document.forms[i++])
{
els = f.elements;
j = 0;
while (el = els[j])
el.index = j++;
}
}
Then access as elementObj.index.
RobB写道:
为什么需要这个?只是很好奇。
Why do you need this? Just curious.
因为我不能使用id而我需要识别该字段。
谢谢你你的回复。
问候,
ABS
Because I can''t use id and I need to identify the field.
Thank you for your response.
Regards,
ABS
RobB写道:
没有运行时循环的唯一方法是使用脚本onload在每个元素上设置索引
属性:
The only way afaik to do it
without run-time looping is to use a script onload that sets an index
property on each element:
还有一个问题。也许你知道热的元素具有特定的
指数?像getElementByIndex()之类的东西?
ABS
One more question. maybe you know hot to get the element having specific
index ? Something like getElementByIndex() ?
ABS
这篇关于表格的字段编号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!