[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

VBScritp loop through checkboxes

Posted on 2006-11-07
3
Medium Priority
?
977 Views
Last Modified: 2009-07-29
I am trying to use VBScript to loop through a number of checkboxes on my form. All the checkboxes named "checnkbox1" through "checkbox10"

Here is my code:

For i=1 to 10
          inField= "opt" & i
         
          'check if checkbox is checked
          if document.forms(0).inField.Checked then    <--EROR HERE
                                       
      ......
          end if
     Next

I get an error "Object property or method 'document.forms(...).inField' is not supported"
0
Comment
Question by:YZlat
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 30

Accepted Solution

by:
callrs earned 500 total points
ID: 17891991
<form>
<input type=checkbox name=opt1 checked>
</form>
      
<script type="text/vbscript">

For i=1 to 2
      inField="opt"&i
      if document.forms(0).elements(inField).checked then
            MsgBox("hey")
      end if
Next
</script
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 17891992
YZlat,

I may have misunderstood your question but if you have provide each checkbox tag with a name attribute value of checkbox# (# is 1-10) then what is opt# (i.e. inField)?  Try changing opt to checkbox and does that correct the problem?  If I have misunderstood or am missing some info then please elaborate.

Let me know if you have any questions or need more information.

b0lsc0tt
0
 
LVL 30

Expert Comment

by:callrs
ID: 17892056
Demo works. inField is a variable not a literal, so you need to use .elements(inField) not .inField
0

Featured Post

Understanding Web Applications

Without even knowing it, most of us are using web applications on a daily basis. Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We often confuse these web applications tools for websites.  So, what is the difference?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
This video teaches users how to migrate an existing Wordpress website to a new domain.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question