中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-03 22:24
48,038 topics / 350,123 posts / today 0 new / 48,251 members
DOS批处理 & 脚本技术(批处理室) » [Solved] Looking for a VBS script to get the value of file(i).value
Printable Version  626 / 2
Floor1 zh159 Posted 2007-03-25 02:12
金牌会员 Posts 1,467 Credits 3,687
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 ]
Floor2 electronixtar Posted 2007-03-25 04:49
铂金会员 Posts 2,672 Credits 7,493
Hint: eval()

For example:

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

[ Last edited by electronixtar on 2007-3-25 at 05:08 AM ]
Floor3 zh159 Posted 2007-03-25 05:31
金牌会员 Posts 1,467 Credits 3,687
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.
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023