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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:28:45+00:00 2026-06-07T07:28:45+00:00

Got a bunch of letter buttons in code below: <?php $a = range(A,Z); ?>

  • 0

Got a bunch of letter buttons in code below:

<?php
    $a = range("A","Z");
?>

<table id="answerSection">
    <tr>

<?php
    $i = 1;
    foreach($a as $key => $val){
        if($i%7 == 1) echo"<tr><td>";
        echo"<input type=\"button\" onclick=\"btnclick(this);\" value=\"$val\" id=\"answer".$val."\" name=\"answer".$val."Name\" class=\"answerBtns answers answerBtnsOff\">";      
        if($i%7 == 0) echo"</td></tr>";
        $i++;
    }
?>
    </tr>
</table>

Now the code below is able to turn on an answer button:

$('#answer'+btn).addClass("answerBtnsOn");

But what I want to do is to be able to turn some answer buttons on and turn the other answer buttons off.

For example if the Answer is A, then I want button “A” to turn on which the above line of code does but I want all of the other letter buttons to turn off. How can I turn off the other letter buttons?

The code here will turn off the letter buttons addClass("answerBtnsOff");,

UPDATE:

I have a little problem as well. If the “Answer” is A, then the letter button “A” is turned on which is fine, but if the Answer is “B D”, then it should turn on letter buttons “B” and “D” but instead it doesn’t turn any buttons on. Does anybody know why this is?

  • 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-07T07:28:46+00:00Added an answer on June 7, 2026 at 7:28 am

    Try the following selector combination:

    $('#answer'+btn1+', #answer'+btn2).addClass("answerBtnsOn").removeClass("answerBtnsOff");
    $('[id^="answer"]').not('#answer'+btn1+', #answer'+btn2).addClass("answerBtnsOff").removeClass("answerBtnsOff");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Got a bunch of letter buttons in code below: Code: <?php $a = range(A,Z);
I just got a bunch of legacy VB6 (!) code dumped on me and
I've got a bunch of legacy Guile Scheme code that I want to get
I've got a bunch of legacy code that I need to write unit tests
I'm got a bunch of html code like this: <a href=http://example.com/project-a title=Project A (test)>Project
I've got a string with a bunch of multi-letter codes in it and I'd
I got a bunch of NSLog statements in my code. Is there anyway I
I've got a bunch of classes that describe database schema: Table,Field,ForeignKey. Tables have ForeignKeys
I've got a bunch of IDL files filled with enums. I would like a
I've got a bunch of lists <ul> <li class=first>Item 1</li> <li>Item 2</li> <li class=last>Item

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.