Solved

EFORM CHECKBOX

Posted on 2009-05-02
4
682 Views
Last Modified: 2012-05-06
On E-form I have 120 checkboxes. On load at least 1 needs to be checked. what code would I used to give error message.

What I have is if obform.checkbox.all = 0 then  
0
Comment
Question by:codefnder
  • 2
4 Comments
 
LVL 9

Expert Comment

by:Tom
ID: 24307154
if obform.checkbox.checked = False then  
Borlean value here:    .checked = True or False

Public Sub Test()
    set input_elements=document.frmname.getElementsByTagName("input")
    for i=0 to input_elements.length-1
        if input_elements(i).type="checkbox" then
                  if input_elements(i).checked=true Then Exit Sub
        end if
    next
' give error message here'
End Sub

Open in new window

0
 

Author Comment

by:codefnder
ID: 24336083
I am receiveing error message when i add this code to my procedure.

The error reads sub is undefined

here is my code


   
   Sub Test()      

    set input_elements=document.OBform.getElementsByTagName("input")
    for i=0 to input_elements.length-1
     if input_elements(i).type="checkbox" then
     if input_elements(i).checked=true Then Exit sub
     end if
     next
    Call msgbox(" Please choose at least 1 Approval option type ", 64, "Error!")
    OBform.OBKey_FeeType_1.FOCUS

  end sub
 
-->
</SCRIPT>

<FORM name=OBForm
action=http://kmweb    Call msgbox(" Please choose at least 1 Approval option type ", 64, "Error!")
    OBform.OBKey_FeeType_1.FOCUS

  end sub
 
-->
</SCRIPT>

<FORM name=OBForm
action=http://kmweb
0
 
LVL 9

Accepted Solution

by:
Tom earned 500 total points
ID: 24344345
OK let me give you a full example you can look at:

<html>
    <head>
        <title>Checkbox</title>
        <script language="vbscript">
        <!--
        sub frmname_onClick
            for each x in document.frmname
                if x.type = "checkbox" then
                    if x.checked = true then
                    exit sub
                    end if
                end if
            next
           
        msgbox "you must select one  "  
        end sub
        -->
        </script>
    </head>
   
    <body>
        <form method="POST" name="frmname">
            <input type="checkbox" name="CH1" /><br/>
            <input type="checkbox" name="CH2" /><br/>
            <input type="checkbox" name="CH3" /><br/>
            <input type="checkbox" name="CH4" /><br/>
            <input type="checkbox" name="CH5" /><br/>
            <input type="checkbox" name="CH6" /><br/>
            <input type="checkbox" name="CH7" /><br/>
            <input type="checkbox" name="CH8" /><br/>
            <input type="checkbox" name="CH9" /><br/>
            <input type="checkbox" name="CH10" /><br/>
            <input type="checkbox" name="CH11" /><br/>
            <br/><br/><input type="submit" value="Submit" name="B1">
        </form>
    </body>
</html>

0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

778 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