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 8227035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:59:00+00:00 2026-06-07T15:59:00+00:00

I have the following sample code which contains two checkboxes. When the user hits

  • 0

I have the following sample code which contains two checkboxes. When the user hits the Submit button I have some JQuery code which determines how many of the checkboxes have been selected.

<html>
<head>
<title>Test</title>


<script src="../../Scripts/jquery-1.5.1.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.validate.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.validate.min.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.validate.unobtrusive.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.validate.unobtrusive.min.js" type="text/javascript"></script>

<script>

    $(function () {
        $('form').submit(function () {

            var fields = $("input[name='group']").serializeArray();
            if (fields.length == 0) {
                //alert('nothing selected');
                $("myText").html("Selected");
            }
            else {
                //alert(fields.length + " items selected");
                $("myText").html("Not Selected");
            }

        });
    });


</script>

</head>
<body>
<div>

    <form>

    <input type="checkbox" name="group" value="1" />1
    <input type="checkbox" name="group" value="2" />2

    <input type="submit" value="Submit" />


    <div id="myText"></div>

    </form>

</div>

If no checkboxes have been selected I can create an alert box which informs the user of this, however, ideally, I would like to to avoid using an alert box, and instead, add some feedback text to a DIV I have created.

You can see I am trying to so this with the following code

$("myText").html("Selected");

But for some reason it doesn’t seem to work.

Can anyone please give me some help with this, it would be greatly appreciated.

Thanks.

Tony.

  • 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-06-07T15:59:03+00:00Added an answer on June 7, 2026 at 3:59 pm

    Missing # in myText please note mytext is id and to access id you need to do this

    $("#myText").html("Selected"); rest should work like rocket.

    hope this helps the cause :)

      $(function () {
            $('form').submit(function () {
    
                var fields = $("input[name='group']").serializeArray();
                if (fields.length == 0) {
                    //alert('nothing selected');
                    $("#myText").html("Selected");
                }
                else {
                    //alert(fields.length + " items selected");
                    $("#myText").html("Not Selected");
                }
    
            });
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following sample code which doesn't seem to want to run. import
I have the following code which creates a simple window with two buttons which
As the following code sample shows, person_list is a user-derived type and contains a
I have the following code: A disposable class that contains two disposable members. One
I have the following very simple code snippet which is loaded from a separate
I have the simple following code, which is working in a ruby (not rails)
I have the following sample code and noticed that if I attempt to use
I have the following code sample that im trying to wrap my head around
I have the following code sample: float val = 16777216.0F; var badResult = Convert.ToDecimal(val);
I have a Dictionary bound to DataGridView by using following sample code. DataGridView bound

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.