There is a table on my page, and each row of the table has two link tags. I want to call the second one by clicking first, because I want to add some parameters for the second href capture from level 1. And the second link opens in the colorbox element.
Tags:
<a id="linkToHiddenATag" href=" '#'.<?php echo $row['employee_id'];?>/<?php echo$row['supervisor_id'];?>" title="Product Operation List">Click for production entry</a>
<a class ="add cboxElement" href="#" id="hiddenATag" ></a>
The full table is as follows:
HTML
<div id="searchPanel">
<table id="searchTable" class="dataTable">
<thead>
<tr>
<th style="text-align: left; width: 8%;">SL</th>
<th style="text-align: left; width: 12%;">Employee Code</th>
<th style="text-align: left; width: 12%;">Employee Name</th>
<th style="text-align: left; width: 12%;">Designation</th>
<th style="text-align: left; width: 10%;">Entry Date</th>
<th style="text-align: left; width: 36%;">Entry</th>
<th style="text-align: center; width: 10%;">D'active</th>
</tr>
</thead>
<tbody>
<?php $loopCount = 1; if(isset($employeeData)){ foreach ($employeeData as $key => $row):?>
<tr id="tr_<?php echo $row['employee_id']; ?>">
<td style="text-align:center;"><input type="text" class="supervisorwiseSerial" id="supervisorwiseSerial_<?php echo $row['employee_id'];?>" name="supervisorwiseSerial_<?php echo $row['employee_id'];?>" value="<?php echo $row['supervisorwise_serial'] ;?>"></td>
<td><?php echo $row['employee_pre_code']."-".$row['employee_code'];?></td>
<td><?php echo $row['employee_name'];?></td>
<td><?php echo $row['designation_name'];?></td>
<td style="text-align: center;">
<input style="width: 80px;" type="text" placeholder="dd.mm.yyyy" class="dateOfProduction_" name="dateOfProduction_" id="dateOfProduction_<?php echo $row['employee_id']; ?>" required />
</td>
<td style="text-align: center;"><a class="btn btn-success btn-xs" id="setSerial_<?php echo $row['employee_id'];?>" role="button" href="#" >Set serial </a> || <a id="linkToHiddenATag" href="<?php echo '#'.base_url();?>production_entry/showOperationList/<?php echo $row['employee_id'];?>/<?php echo$row['supervisor_id'];?>" title="Product Operation List">Click for production entry</a></td>
<td style="text-align:center"><a class="btn btn-warning btn-xs" id="deActiveEmployee" href="<?php echo base_url().'employee'.'/'.'#'.'editOrDeactivate'.$row['employee_id'];?>" target="_blank">D'active Emp</a></td>
<input type="hidden" id="employeeId" value="<?php echo $row['employee_id']; ?>">
<input type="hidden" id="unit_<?php echo $row['employee_id']; ?>" value="<?php echo $row['unit_id']; ?>">
<input type="hidden" id="floor_<?php echo $row['employee_id']; ?>" value="<?php echo $row['floor_id']; ?>">
<input type="hidden" id="section_<?php echo $row['employee_id']; ?>" value="<?php echo $row['section_id']; ?>">
<input type="hidden" id="subsection_<?php echo $row['employee_id']; ?>" value="<?php echo $row['subsection_id']; ?>">
<input type="hidden" id="incharge_<?php echo $row['employee_id']; ?>" value="<?php echo $row['incharge_id']; ?>">
</tr>
<?php $loopCount++; endforeach;}?>
</tbody>
</table>
</div>
<div class="panel-footer" style="text-align: right;" id="searchPanelFooter">
<a id="saveAll" name="saveAll" class="btn btn-success btn-md" role="button" href="#">Save All</a>
<a class ="add cboxElement" href="#" id="hiddenATag" ></a>
</div>
JavaScript:
$(document).on('click', 'a#linkToHiddenATag', function() {
var url = $(this).attr("href");
var arrfor = url.split('/');
var lengthto = arrfor.length;
var employeeSysIdForOpList = arrfor[lengthto - 2];
var supervisorIdForOpList = arrfor[lengthto - 1];
var prodOpGrp = parseInt($('select#operationGroupSelect').val());
var newhref = '';
if ($.isNumeric(prodOpGrp)) {
newhref = '<?php echo base_url().'
production_entry / showOperationList / ';?>' + employeeSysIdForOpList + '/' + supervisorIdForOpList + '/' + prodOpGrp;
} else {
newhref = '<?php echo base_url().'
production_entry / showOperationList / ';?>' + employeeSysIdForOpList + '/' + supervisorIdForOpList;
}
$('a#hiddenATag').removeProp("href");
$('a#hiddenATag').prop("href", newhref);
$('a#hiddenATag').click();
});
The problem is that the click event only works once. He never shoots again. I could not detect the problem. Useful if someone can help.
source
share