Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7004985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:16:15+00:00 2026-05-27T21:16:15+00:00

This has me pulling my hair out. Button on site has onclick=method() and it’s

  • 0

This has me pulling my hair out. Button on site has onclick=method() and it’s not calling the method. The method is supposed to grab all the checkboxes, check their checked state and fill the chk[] array with true/false. The WebMethod then takes that array, breaks it down into three smaller arrays and runs checks on the combinations. So far as I can tell, the button never calls the method to begin with.

aspx page:

<fieldset id="Fieldset">
     <button onclick="SendForm();">Send</button>
     &nbsp;
     <button onclick="CancelForm();">Cancel</button>
</fieldset>
</form>
<asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true" EnablePartialRendering="true" runat="server" />

<script type="text/javascript">
    function SendForm() {
        var email = $get("txtEmail").value;
        var elLength = form1.elements.length;
        var chk = new [42];
        for (i = 0; i < elLength; i++) {
            var count = 0;
            var type = form1.elements[i].type;
            if (type == "checkbox") {
                if (form1.elements[i].checked) {
                    chk[count] = true;
                }
                else {
                    chk[count] = false;
                }
                count++;
            }
            else {
            }
        }
        PageMethods.SendForm(email, chk, OnSucceeded, OnFailed);
    }
</script>

codebehind method it’s calling:

[WebMethod]
public static void SendForm(string email, bool[] chk)
{
    bool[] desc = new bool[14];
    bool[] loc = new bool[14];
    bool[] other = new bool[14];
    for (int i = 0; i < 14; i++)
    {
        int count = i * 3;
        desc[i] = chk[count];
        loc[i] = chk[count + 1];
        other[i] = chk[count + 2];

    }
    if (string.IsNullOrEmpty(email))
    {
        throw new Exception("You must supply an email address.");
    }
    else
    {
        if (IsValidEmailAddress(email))
        {
            for (int i = 0; i < 14; i++)
            {
                if (desc[i])
                {
                    if ((loc[i]) && (other[i]))
                    {
                        throw new Exception("Invalid, two parameters selected");
                    }
                    else if (loc[i])
                    {
                        // do stuff
                    }
                    else if (other[i])
                    {
                       // do stuff
                    }
                    else
                    {
                        throw new Exception("Invalid, every exemption must have at least one reason selected");
                    }
                }
                else
                {
                    throw new Exception("No exemptions have been selected");
                }
            }
        }
        else
        {
            throw new Exception("You must supply a valid email address.");
        }
    }
}

EDIT!!:
Running the page with the following script instead of the previous script works like a charm. No clue why the previous didn’t work.

<script type="text/javascript">
    function SendForm() {
        var email = $get("txtEmail").value;
        var elLength = form1.elements.length;
        for (i=0;i< elLength;i++) {
            var type = form1.elements[i].type;
            if (type == "checkbox" && form1.elements[i].checked) {
                alert("true!");
            }
            else {
                alert("false!");
            }
        }
        PageMethods.SendForm(email, chk, OnSucceeded, OnFailed);
    }
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:16:16+00:00Added an answer on May 27, 2026 at 9:16 pm

    Running the page with the following script instead of the previous script works like a charm. No clue why the previous didn’t work.

    <script type="text/javascript">
        function SendForm() {
            var email = $get("txtEmail").value;
            var elLength = form1.elements.length;
            for (i=0;i< elLength;i++) {
                var type = form1.elements[i].type;
                if (type == "checkbox" && form1.elements[i].checked) {
                    alert("true!");
                }
                else {
                    alert("false!");
                }
            }
            PageMethods.SendForm(email, chk, OnSucceeded, OnFailed);
        }
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This one has me pulling my hair out. I'm trying to implement a very
This one has had me pulling out my hair. I've been trying to deserialize
I'm pulling my hair out on this one. I have a site which is
I've been pulling my hair out on this one all afternoon. Basically, I have
This problem of mine has me pulling my hair out. It's related to the
This has me pulling my hair out. We have a workflow, hosted as a
I just spent a few hours pulling my hair out over this. I'm trying
I've been pulling my hair out for the last few hours with this problem.
I've been pulling my hair out trying to fix this issue. if I go
I've been pulling my hair for three days trying to figure out what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.