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

The Archive Base Latest Questions

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

Below is the code I have where it is suppose to display the number

  • 0

Below is the code I have where it is suppose to display the number within the textbox when the “Add” button is clicked on $('#mainNumberAnswerTxt').val(numberAnswer);. But I also have a line of code where it triggers the function for when a (btn ‘button’) is clicked on.

 function addwindow(numberAnswer, gridValues, btn) { 
    $('#mainNumberAnswerTxt').val(numberAnswer);
    $('#btn'+gridValues).trigger('click');       
 }

Because of the trigger it triggers this function $('.gridBtns').on('click', function(). In this function is this line of code

$('.answertxt', context).val(context.find('.answerBtnsOn').length > 0 ? context.find('.answerBtnsOn').length : '');,

This line of code checks for how many buttons were turned on when the gridBtn is clicked and displays the number in the textbox. But the line of code above is overwriting the $('#mainNumberAnswerTxt').val(numberAnswer); in the addwindow() function.

EXAMPLE:

If there were 2 ‘#btns’ which were turned on but then I click on the “Add” button to add the number displayed under the “Number of Answers” column (lets say this number is 1), then it should display number 1 in the textbox by this code taking affect $('#mainNumberAnswerTxt').val(numberAnswer);, but instead it is displaying number 2, because this code is taking affect: $('.answertxt', context).val(context.find('.answerBtnsOn').length > 0 ? context.find('.answerBtnsOn').length : '');

How can I get number 1 to be displayed and not number 2 to be displayed in the example above

Below is html code of textbox:

<input type="text" name="numberAnswer" class="numberAnswerTxt answertxt" id="mainNumberAnswerTxt" readonly="readonly" onChange="getButtons()" >

UPDATE:

Here is a demo of the application. Please follow the steps below:

  • Step 1: When you open up the demo, click on the “Open grid” link and
    select button “7”. This will display a textbox and 7 letter buttons
    underneath.
  • Step 2: Select 4 letter buttons underneath of you choice. You will
    see when you turn on a letter button the textbox above counts it.
  • Step 3: Now on left hand side you will see a green plus button, click
    on it and it opens up a modal window.
  • Step 4: In modal window there is a search bar, type in “AAA” and
    submit search, you will see a bunch of rows appear.
  • Step 5: In the first row, you see under “Number of Answer” colum that
    it contains the number 1, click on the “Add” button within this row,
    the modal window will close but there is problem which you can read
    below.

Problem:

In the “Number of Answers” textbox, it should display the number 1, but it doesn’t.

  • 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:15:53+00:00Added an answer on June 7, 2026 at 3:15 pm

    Ok, this question is quite confusing, but I think i figured out what you want:
    Just add a class or attribute to the mainNumberAnswerTxt so it can be ignored by the second on click event

    function addwindow(numberAnswer, gridValues, btn) { 
        $('#mainNumberAnswerTxt').val(numberAnswer).attr('data-ignore',true);
        $('#btn'+gridValues).trigger('click');       
    }
    

    and then in your $(‘.gridBtns’).on(‘click’, function() you simply check (don’t know your exact html & js-code)

    if(this).attr('data-ignore') != true {
        $('.answertxt', context).val(context.find('.answerBtnsOn').length > 0 ?      context.find('.answerBtnsOn').length : '');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a php code below where it is suppose to display my buttons,
Suppose I have an XSD file having below lines of code; <xsd:simpleType name=test> <xsd:restriction
I have code below: <select id=testSelect> <option value=1>One</option> <option value=2>Two</option> </select> <asp:Button ID=btnTest runat=server
I have the below code which is suppose to show a list of contact
Hi Suppose I have the code below: <div class=Hello> <div class=inner>Hello</div> </div> <div class=Goodbye>
Hi Suppose I have the code below: [taxonomy] => Array ( [118] => stdClass
The code I have below joins 5 tables and then is suppose to sort
Problem: In the Number of Answers textbox, it should display the number 1, but
I have below code: <a href=# id=@item.Id name=vote ><img src=/Content/images/021.png style=float:left alt= /></a> which
I have below code: class Program { static void Main(string[] args) { Task[] tasks

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.