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
我必须在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
结束功能
我需要返回此数组才能使用它,感谢提前,我尝试过在线查看,但似乎无法解决这个问题。
答案 0 :(得分:4)
问题解决了,我使用了不正确的语法,并且不得不重新调整数组 - 只是在这种情况下这有助于其他人
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
你可以在另一个循环中替换第二个索引,