作者:mobiledu2502921033 | 来源:互联网 | 2023-05-18 01:19
Iamredesigningapartofawebpagetomakeiteasiertoupdateinthefuture.Currently,itisas
I am redesigning a part of a webpage to make it easier to update in the future. Currently, it is a series of tables, that are hard-coded. To redesign the table (for example, to alphabetize it like I want to), requires manually swapping around a lot of values in the html.
我正在重新设计网页的一部分,以便将来更容易更新。目前,它是一系列硬编码的表。要重新设计表格(例如,按照我想要的方式按字母顺序排列),需要手动交换html中的大量值。
This is what I'd like to do: Create a url_Link object with a title and link variable, to hold the display name and the url respectively. Create an array of url_Link objects, and populate it at the top of the .asp file for the page. Perform a for each loop on those arrays to build and populate the table
这就是我想要做的:创建一个带有标题和链接变量的url_Link对象,分别保存显示名称和URL。创建一个url_Link对象数组,并将其填充到页面的.asp文件的顶部。对这些阵列上的每个循环执行a以构建和填充表
This itself isn't so bad, but I run into two problems. First, I'd like to not have to define the array size, as this makes a second place that has to be changed when changes are made to the number of links. There will be some logic to prevent certain url_Link objects from being displayed (for example, some users can't access certain pages, so they will not see links), and this would cause issues when sizing the arrays.
这本身并不是那么糟糕,但我遇到了两个问题。首先,我不想定义数组大小,因为当对链接数进行更改时,这是第二个必须更改的地方。将有一些逻辑来阻止显示某些url_Link对象(例如,某些用户无法访问某些页面,因此他们将看不到链接),这会在调整数组大小时引起问题。
I know that I could just make the arrays of a large size, but this seems wasteful to me (and I don't know how for each functions and do not want a bunch of empty rows to show up).
我知道我可以制作一个大尺寸的数组,但这对我来说似乎很浪费(而且我不知道每个函数如何,也不希望出现一堆空行)。
What can I do to resolve these problems? I'm not very knowledgeable in Vbscript, and most of the code that I have been working with does not take advantage of arrays or objects.
我该怎么做才能解决这些问题?我对Vbscript知之甚少,而且我一直在使用的大部分代码都没有利用数组或对象。
UPDATE: I've tried using a redim PRESERVE to trim the excess fat of an oversized array. The problem is that in some cases, my array is populated by smaller amounts of objects than its max size because of if conditions. This is causing problems later when I use a for loop (tried to get a for each to work and that is not happening at the moment). I get the error "This array is fixed or temporarily locked" on the redim line
更新:我尝试使用redim PRESERVE来修剪超大阵列的多余脂肪。问题是,在某些情况下,由于if条件,我的数组中填充的对象数量少于其最大大小。当我使用for循环时,这会导致问题(尝试为每个循环工作并且目前没有发生)。我在redim行上收到错误“此数组已固定或暂时锁定”
Code:
dim systemSettingsArray(1)
arrayCounter = 0
if ADMIN = "Y" then
set systemSettingsArray(arrayCounter) = (new url_Link).Init("Account Administration","Maintenance/Account_Admin.asp")
arrayCounter = arrayCounter + 1
end if
set systemSettingsArray(arrayCounter) = (new url_Link).Init("Time Approval","Maintenance/system_Time_Approval.asp")
redim Preserve systemSettingsArray(arrayCounter)
2 个解决方案