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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:29:37+00:00 2026-06-07T17:29:37+00:00

I have a line of code below which successfully does a trigger when a

  • 0

I have a line of code below which successfully does a trigger when a grid button is clicked. This is belw:

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

The trigger works with this code below:

     <table id="optionAndAnswer" class="optionAndAnswer">
    <tr>
          <th colspan="2">
            Option and Answer
        </th>
    </tr>
    <tr class="option">
    <td>1. Option Type:</td>
    <td>
    <div class="box">
        <input type="text" name="gridValues" class="gridTxt maxRow" id="mainGridTxt" readonly="readonly" />
        <span href="#" class="showGrid" id="showGridId">[Open Grid]</span>
    </div>

    <?php
        $num = range("3","26");
    ?>

          <table class="optionTypeTbl">
            <tr>

                <?php
                $i = 1;
                foreach($num as $key => $val){
   if($i%7 == 1) echo"<tr><td>";
   echo"<input type=\"button\" value=\"$val\" id=\"btn".$val."\" name=\"btn".$val."Name\" class=\"gridBtns gridBtnsOff\">";        
                    if($i%7 == 0) echo"</td></tr>";
                    $i++;
                }
                ?>

                    </tr> 
                    </table>
    </td>
    </tr>
    </table>

What the trigger code does is lets say the user clicks on the grid button (btn) 4, then it will display 4 answer buttons A,B,C,D. Another example is if the user clicks on grid button 7, it will display 7 answer buttons A,B,C,D,E,F,G.

But I have another piece of code below where it is like a template or a copy of the option control you see in the above code.

    function insertQuestion(form) {    

        var context = $('#optionAndAnswer');

            var $tbody = $('#qandatbl > tbody'); 
            var $tr = $("<tr class='optionAndAnswer' align='center'>");
            var $options = $("<div class='option'>Option Type:<br/></div>");
            var $questionType = '';


            $('.gridTxt', context).each( function() {

            var $this = $(this);
            var $optionsText = $("<input type='text' class='gridTxtRow maxRow' readonly='readonly' />")
            .attr('name',$this.attr('name')+"[]")
            .attr('value',$this.val())
            .appendTo( $options )
            .after("<span href='#' class='showGrid'>[Open Grid]</span>");

            $questionType = $this.val();

            });


            $td.append($options);
            $tbody.append($tr); 

        }

My question is that if in the first code the trigger is $('#btn'+gridValues).trigger('click');, then what should the trigger code be for the second code to be able to select the grid button from the second code?

UPDATE:

I have created a url for this application here. Please follow the steps to use the application and then you can see what is happening:

  • Step 1: When you open applicaton, you see a green plus button on the
    page, click on it and it will display a modal window.
  • Step 2: In modal window there is a search bar, type in “AAA” and
    submit search, you will see a bunch of rows appear.
  • Step 3: In the first row, you see under “Option Type” A-D, click on
    the “Add” button within this row, the modal window will close and you
    see in the grey textbox on right hand side that “Option Type” textbox
    equals 4 and it displays the Answer buttons A,B,C and D, this is
    because as you remember the option tpye for that row was “A-D”.

Now this works fine but it only works for the top option and answer control, follow the steps below:

  • Step 4: Click on the “Add Question” button, it adds a row underneath
    containing the details from the option and answer control on top.
  • Step 5: Within the row you have just added, you see a geen plus
    button on left hand side, click on this button and perform the same
    search “AAA” in search box.
  • Step 6: This time select the last row by clicking on its “Add”
    button, the “Option Type” for this row is “A-G” so it should display
    “Answer” buttons A,B,C,D,E,F and G, but it doesn’t do this, it still
    states “A,B,C,D”. This is why I want to know what the trigger click
    function is for when the user adds an option type within one of the
    added rows, so it changes the answer buttons to match the option
    type.
  • 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-07T17:29:39+00:00Added an answer on June 7, 2026 at 5:29 pm

    If you want to trigger a click on a <span> that follows an <input type="text" class="gridTxtRow maxRow"> with a value of VAL, you can do this:

    $('input.gridTxtRow[value="VAL"] + span').trigger('click');
    

    The selector A + B selects any B element that is the next sibling of an A element.


    Update: There are some things you need to fix before getting this to work:

    1. Element IDs are suppose to be unique, i.e. there is only one element with a particular ID in the whole page. When you generate the input.gridBtns for a new option, it has IDs (btn3, btn4, etc.) as the buttons for the first option. Browsers will let you do this, but JavaScript that uses those IDs will become unpredictable.

    2. The input.gridBtns for a new option are only generated when the user clicks [Open Grid]. If the user clicks on the green plus button before clicking [Open Grid], then there are no buttons to call .trigger() on. I suggest when you add a new option, you add those buttons as well.

    After these fixes, if you change this line:

    $(plusbutton_clicked).closest('tr').find('input.gridTxtRow').val(gridValues);
    

    to this:

    $(plusbutton_clicked).closest('tr')
        .find('input.gridTxtRow').val(gridValues).end()
        .find('input.gridBtns[value="' + gridValues + '"]').trigger('click');
    

    it should do what you’re looking for.


    Update #2: Sorry, I thought you were adding new buttons after [Open Grid] when in fact you’re moving <table class="optionTypeTbl"> around.

    Instead of the previous $(plusbutton_clicked)... code, try this:

    $(plusbutton_clicked).closest('tr')
        .find('input.gridTxtRow').val(gridValues)
            .parent().append($('.optionTypeTbl'));
    
    $('#btn' + gridValues).trigger('click');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Below I have a line of code where it states which Session a user
I have this GWT code below which have some slight problem: It's either the
I have the line of code below... How would I modify it to insert
I have this line of code but it throws an error. What is the
I have one line of code which seems commented. Basically the thing I want
I have this line of code: this.Path = pathLookUpLocation.GetValue(RegLookupKey, null).ToString(); When I run static
I have this line of code: System.Drawing.Icon icon = System.Drawing.Icon.FromHandle(shinfo.hIcon); A few lines later,
I have the code below which I am using to upload files to my
So, I have the code below which works fine when entered into Google's Rich
I have some code below which will not run due to me not being

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.