use*_*802 1 multidimensional-array asp-classic
ASP新手。尝试从表单创建多维数组。在PHP中这就像
<?php
$myArray = array();
for($i = 0 $i< $myArray.size() $i++){
myArray[$i] = array(field1=>"var1",field2=>var2);
}
?> //syntax not exactly correct but you get the picture
Run Code Online (Sandbox Code Playgroud)
我必须在ASP中做类似的事情,但是我似乎可以弄清楚,尽管它应该很简单
我需要从表单的行中获取完成的值,然后将值放入数组中
Function getResults(totalRows)
dim results() 'my array for results
for i = 0 to totalRows - 1
color = request.form("color"&i)
width = request.form("width"&i)
height = request.form("height"&i)
results(i)("color") = color
results(i)("height") = height
results(i)("width") = width
response.write("color is " &results(i)("color")
response.write("color is " &results(i)("height")
response.write("color is " &results(i)("width")
NEXT
Run Code Online (Sandbox Code Playgroud)
结束功能
我需要返回此数组以使用它,在此先感谢,我尝试过在线查找,但似乎无法解决。
问题解决了,我使用了不正确的语法,不得不重新调数组-以防万一这对其他人有帮助
dim results() 'my array for results
ReDim Results(totalRows, 3)
for i = 0 to totalRows - 1
results(i,0) = color
results(i,1) = height
results(1,2) = width
response.write("color is " &results(i,0)
response.write("color is " &results(i,1)
response.write("color is " &results(i,2)
NEXT
Run Code Online (Sandbox Code Playgroud)
您可以在另一个循环中替换第二个索引,