问题描述
我有一个问题,可能是愚蠢的,但我不能让它工作...
I got a question that is probably stupid, but I'm not able to make it work...
我提交包含这样输入的表单:
I'm submitting a form which contains inputs like this:
<input type="hidden" id="hidden0" name="Options2" value="0" />
<input type="hidden" id="hidden1" name="Options2" value="30" />
<input type="hidden" id="hidden2" name="Options2" value="4" />
<input type="hidden" id="hidden3" name="Options2" value="-1" />
<input type="hidden" id="hidden4" name="Options2" value="-1" />
<input type="hidden" id="hidden5" name="Options2" value="-1" />
<input type="hidden" id="hidden6" name="Options2" value="-1" />
<input type="hidden" id="hidden7" name="Options2" value="-1" />
请注意,这些8输入动态创建的。当点击提交后,我得到的所有的名称=选项动态创建的投入,并把值放入一些通用的输入。
Note that these 8 inputs are created dynamically. When submit is clicked, I get all the inputs created dynamically with the name="Options" and put the values into some general inputs.
var inputs = document.getElementsByName("Options"+cpt);
for( var g = 0; g < 8; g++ )
{
document.all.Options[g].value = inputs[g].value;
}
当我收到的形式,我得到这个行:
When I receive the form, I got this line:
var arrayOption = Request.Form("Options");
如果我的Response.Write(arrayOption),我可以看到的结果:0,30,4,-1,等等...
我试图让一个像这样的循环中的所有值:
If I Response.Write(arrayOption), I can see the result: 0, 30, 4, -1, etc...I'm trying to get all values inside a loop like this:
for (var k = 0; k < arrayOption.count; k++) {
Response.Write(arrayOption[k]);
}
在这种情况下,arrayOption [K]是不确定的,我不知道为什么。我还注意到,arrayOption.length不工作(这就是为什么我用.Count之间)。它看起来像arrayOption并不是一个真正的数组,所以我试图分裂,但对象不支持此属性或方法。这有什么错这一切?
In this case, arrayOption[k] is undefined and I don't know why. I also noticed that arrayOption.length is not working (this is why I used .count). It looks like arrayOption is not a true array, so I tried to split, but Object doesn't support this property or method. What's wrong with all this?
推荐答案
那么这看起来的像ASP经典+服务器端JScript,所以你需要一个枚举()
走集合,如:
Well that looks like ASP Classic + Server side JScript so you need an Enumerator()
to walk the collection, E.g.
for (var e = new Enumerator(Request.Form); !e.atEnd(); e.moveNext())
Response.Write(e.item() + "=" + Request.Form(e.item()) + "<br>");
枚举所有的post数据
Enumerates all the post data
这篇关于JScript的数组的Request.Form的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!