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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:02:13+00:00 2026-06-07T04:02:13+00:00

I have a function below where if the user clicks on the Add button,

  • 0

I have a function below where if the user clicks on the “Add” button, it triggers the function below:

function addwindow(gridValues) { 

    if($(plusbutton_clicked).attr('id')=='mainPlusbutton') { 

        $('#btn'+gridValues).trigger('click');


        } 

    $.modal.close(); 
    return false;
} 

Now below is the code where it is able to display answer buttons A-Z, “True” or “False” and “Yes” or “No”:

Html code:

<?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>
    <tr>
<td>
<input class="answerBtns answers" name="answerTrueName"  id="answerTrue"    type="button"   value="True"    onclick="btnclick(this);"/>
<input class="answerBtns answers" name="answerFalseName" id="answerFalse"   type="button"   value="False"   onclick="btnclick(this);"/>
<input class="answerBtns answers" name="answerYesName"   id="answerYes"     type="button"   value="Yes"     onclick="btnclick(this);"/>
<input class="answerBtns answers" name="answerNoName"    id="answerNo"      type="button"   value="No"      onclick="btnclick(this);"/>
</td>
</tr>
</table>

Javascript code:

function getButtons()
{
    var i;
    if (initClick == 0) {
        for (i = 65; i <= 90; i++) { // iterate over character codes for A to Z
            $("#answer" + String.fromCharCode(i)).removeClass("answerBtnsOn").addClass("answerBtnsOff");

        }

        initClick = 1;
    }
    // code above makes sure all buttons start off with class answerBtnsOff, (so all button are white).
}

Below is the code where it turns on and off the answer buttons:

function btnclick(btn)
{
    var context = $(btn).parents('#optionAndAnswer');

    if ($(btn).hasClass("answerBtnsOn")) {
        $(btn).removeClass("answerBtnsOn").addClass("answerBtnsOff");
        return false;
    }

    if ($(btn).hasClass("answerBtnsOff")) {
        $(btn).removeClass("answerBtnsOff").addClass("answerBtnsOn");
        return false;
    }
}

Now I have a table column known as “Answers” and each row under that column contains as Answer(s) and its own “Add” button. What my question is that if lets say in one of the rows contains the Answer A B D F and the user adds this row by clicking on the “Add” button, then I want the answer buttons A B D and F to be turned on and the other answer buttons to be turned off. Another example is if the Answer is True, then I want the True answer button to be turned on and the other answer buttons to be turned off.

So what do I need to put in the function addwindow(gridValues) so that when the “Add” button is clicked, its turns on and turn off the correct answer buttons?

  • 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-07T04:02:15+00:00Added an answer on June 7, 2026 at 4:02 am

    Passing the id on click in this way it works for me debugging with selenium:

    $('input').click(function() {
        var id = $(this).attr('id');
        btnclick(id);
    }
    

    I just removed on the html markup the onclick behavior.

    Hope it works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two pages, product.php and viewcart.php. When a user clicks on a button
Below is the Html button and javascript function I have which closes a modal
I have the function below. It gets the values from checked boxes and transfer
let say i have function like below function doSomethingNow(){ callSomethingInFutureNotExistNow(); } at the moment
I have written a function below: void trans(double x,double y,double theta,double m,double n) {
I have the following function below: public function setupHead($title){ $displayHead .='<!DOCTYPE html PUBLIC -//W3C//DTD
I have an example function below that reads in a date as a string
I have a function as below extern C int FuncTrace(const char *fmt, ...) {
I have a problem using the string function erase with iterators. The function below
I decided to have a go at PDO. The function below should move a

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.