China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-03 23:27
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Solved] Looking for a VBS script to get the value of file(i).value View 627 Replies 2
Original Poster Posted 2007-03-25 02:12 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
Checkboxes:
<input type="checkbox" id="file1" name="file1" value="FileName1">
<input type="checkbox" id="file2" name="file2" value="FileName2">
<input type="checkbox" id="file3" name="file3" value="FileName3">
<input type="checkbox" id="file4" name="file4" value="FileName4">


To get the values of the checked checkboxes, you can use:
if file1.checked then MsgBox file1.value
if file2.checked then MsgBox file2.value
if file3.checked then MsgBox file3.value
if file4.checked then MsgBox file4.value


But if there are a lot of them, then the if script has to grow to the same number as well (the number of checkboxes adjusts automatically according to how many files there are).

I tried
for i = 1 to Num
if file(i).checked then MsgBox file(i).value)
next

but that method doesn't work. I couldn't find a way to solve it online, so I'm asking whether there are any VBS experts who can solve this?

[ Last edited by zh159 on 2007-3-24 at 04:32 PM ]
Floor 2 Posted 2007-03-25 04:49 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
Hint: eval()

For example:

i=1
msgbox eval("file" & i & ".checked")

[ Last edited by electronixtar on 2007-3-25 at 05:08 AM ]
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
zh159 +15 2007-03-25 05:30

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 3 Posted 2007-03-25 05:31 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
Originally posted by electronixtar at 2007-3-24 15:49:
Hint: eval()

For example:

i=1
msgbox eval("file" & i & ".checked")


Got it working, many thanks.
Forum Jump: