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

  • SEARCH
  • Home
  • 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 897811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:56:32+00:00 2026-05-15T14:56:32+00:00

I have this span that is in a loop and produce multiple results. what

  • 0

I have this span that is in a loop and produce multiple results.
what I want is the attribute recordID value when its checked

<span  id="row" index="<?php print $i; ?>" recordID="<?php print $row->ID; ?>"  Color="<?php print $row->Color; ?>">  
<input type="checkbox" style="left:10;" />  
</span>

I am using this in my js file to check if the checkbox was clicked

var test =  $('input:checkbox:checked').val();      
alert(test);

And all I get is on
how can I get attribute value
Thanks

  • 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-15T14:56:33+00:00Added an answer on May 15, 2026 at 2:56 pm

    This will get you the attribute value

    $('#row').attr('recordID');
    

    If you wanted to get the value when the checkbox gets checked, here is an example

    js file

    $(document).ready(function(){
     $('input:checkbox').change(function(){
      if($(this).attr('checked')){
       alert($(this).parent().attr('recordID'));
      }
     });
    });
    

    To see how many rows have been checked:

    JavaScript

    $(document).ready(function(){
     $('#check').click(function(event){
      event.preventDefault();
      alert($('input:checkbox:checked').size());
     });
    });
    

    HTML

    <span  id="row1" recordID="1">  
     <input type="checkbox" style="left:10;" />  
     <input type="checkbox" style="left:10;" />  
     <input type="checkbox" style="left:10;" />  
     <input type="checkbox" style="left:10;" />  
    </span>
    <span  id="row2" recordID="2">  
     <input type="checkbox" style="left:10;" />  
    </span>
    <span  id="row3" recordID="3">  
     <input type="checkbox" style="left:10;" />  
    </span>
    <span  id="row4" recordID="4">  
     <input type="checkbox" style="left:10;" />  
    </span>
    <button id='check'>Check Num Rows</button>
    

    To check within an individual span

    $(document).ready(function(){
        $('#check').click(function(event){
            event.preventDefault();
            alert($('#row1 input:checkbox:checked').size());
        });
    });
    

    Here is the complete sample code i am using to make the example you need

    <html>
    <head>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
    
    <script type='text/javascript'>
    $(document).ready(function(){
        $('input:checkbox').change(function(){
            alert($(this).parent().find(':checkbox:checked').size());
        });
    });
    </script>
    </head>
    <body>
    <span  id="row1" recordID="1">  
        <input type="checkbox" style="left:10;" />  
        <input type="checkbox" style="left:10;" />  
        <input type="checkbox" style="left:10;" />  
    </span><br/><br/>
    <span  id="row2" recordID="2">  
        <input type="checkbox" style="left:10;" />  
        <input type="checkbox" style="left:10;" />  
        <input type="checkbox" style="left:10;" />  
        <input type="checkbox" style="left:10;" />  
    </span><br/><br/>
    <span  id="row3" recordID="3">  
        <input type="checkbox" style="left:10;" />  
        <input type="checkbox" style="left:10;" />  
        <input type="checkbox" style="left:10;" />  
        <input type="checkbox" style="left:10;" />  
    </span><br/><br/>
    <span  id="row4" recordID="4">  
        <input type="checkbox" style="left:10;" />  
        <input type="checkbox" style="left:10;" />  
        <input type="checkbox" style="left:10;" />  
        <input type="checkbox" style="left:10;" />  
    </span>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a variable that has this string: <DIV><SPAN style=FONT-FAMILY: Tahoma; FONT-SIZE: 10pt>[If the
I have a composite control which emits HTML that looks like this <span id=myControl>
i have this <li><a href=# >title</a> <span style='text-align:right;'>(0)</span></li> its not working and this <li><a
I have this structure on form, <input type=test value= id=username /> <span class=input-value>John Smith</span>
So I have this simple HTML: <span id=badge>0</span> I want the number 0 to
I have a while and foreach loop that I want to use to print
I have html that looks like this, <div> <span>Text <a href=example.html>ABC</a> <a href=example.html>DEF</a> <a
I have a unordered list that contains <ul id=strip> <li><a href=#><span>This-is a test string</span></a></li>
i have this html: <span class=price> $61.00 <span class=detailFreeShipping>With Free Shipping</span> </span> How to
i have this code $(function() { $('#ans_vote a span').click(function(){alert('working');return false;});}); and this html <div

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.