php - How to add trigger event at end of this line of code at bottom -


at top of page, have option , answer control user able select option grid , relevant answer buttons appear depending on option selected.

below html code stores option , answer control features:

option , answer control on top of page:

<table id="optionandanswer" class="optionandanswer"> <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 $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> <tr class="answer"> <td>3. answer</td> <td> <?php $a = range("a","z"); ?> <table id="answersection"> <tr> <?php $i = 1; foreach($a $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> </td> </tr> </table> 

the line of code displays correct number of answer buttons after add button clicked on code:

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

now havn't included piece of code user able click on "add" button add option type option type textbox. when option type inserted textbox, automatically selects option button option value matches in grid, because of this, trigger code above able display correct number of answer buttons seeing option type selected grid.

the problem have works option , answer control on top of page only. user able add rows in application , in each row, adds it's own option , answer control. code appending , answer , option control within row below:

 function insertquestion(form) { var $tbody = $('#qandatbl > tbody'); var $tr = $("<tr class='optionandanswer' align='center'>"); var $options = $("<div class='option'>option type:<br/></div>"); var $answer = $("<div class='answer'>answer:<br/></div>"); $('.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(); }); var $this, i=0, $row, $cell; $('#optionandanswer .answers').each(function() { $this = $(this); if(i%7 == 0) { $row = $("<tr/>").appendto($answer); $cell = $("<td/>").appendto($row); } var $newbtn = $("<input class='answerbtnsrow answers' type='button' style='display:%s;' onclick='btnclick(this);' />".replace('%s',$this.is(':visible')?'inline-block':'none')).attr('name', $this.attr('name')).attr('value', $this.val()).attr('class', $this.attr('class')); $newbtn.appendto($cell); i++; }); $td.append($options); $td.append($answer); $tbody.append($tr); } 

so question if trigger: $('#btn'+gridvalues).trigger('click'); works main option , answer control on top, how can include trigger able display correct number of answer buttons in answer , option control within particular row?

i have starting code able find row, need on how include trigger @ end of code there no #btn in option , answer controls in rows:

$(plusbutton_clicked).closest('tr').....; 

so, you'll need modify work, work?

$(plusbutton_clicked).closest('tr').find(".answerbtnsrow").click(); 

Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -