0

I have an accordion table and i want to get the row id values using Jquery and checkboxes.To make things easier i am using a hidden value field.when i try to do that hidden input id always set to the last row value instead giving me all the values.

My accordion table innerHTML is like this

<div id="acc22" class="accBox">
<p class="accordianHead">
<div class="accordianBody">
<form id="form_22" action="" method="post" encoding="">
<div style="display:none;">
<table id="item_tbl_22" class="accTable" cellspacing="0" cellpadding="0" border="0" width="100%">
<thead class="greyBg paddingHead">
<tbody>
<input id="cloth_id22" type="hidden" value="72" name="fabric_id">
<input id="cloth_colour_id22" type="hidden" value="824" name="data[Cloth][cloth_id]">
<tr id="S3639-1-1_824" style=" ">
<tr id="S3639-1-2_824" style=" ">
<tr id="S3639-1-3_824" style=" ">

<tr>
</tbody>
</table>
</form>
</div>

This is my hidden id

 <input type="hidden" id="form_te[<?php echo  $id;?>]" value="<?php echo  $tbl_content;?>" />

This is my Jquery method

 $("input[name='s_i_width[]']:checked").each(function(event) {

printArray.push($('#form_te'+ this.value).val());
  console.log($('#form_te'+ this.value).val());

How to archive this?

Newbie
  • 19
  • 4

2 Answers2

0

Sorry about that, i think the special character need to add extra code. Try this.

$("#form_te\\["+<?php echo  $id;?>+"\\]").val()

And thanks for this guys. Find DOM element by ID when ID contains square brackets?

Community
  • 1
  • 1
  • But you must put this code in ur same php file. so that the jquery element will generate correctly. – Ng Sheng Kee May 20 '16 at 08:53
  • This gives me the id value last row of the table, not the selected values, if i select 3 checkboxes and it prints last 3 row id 3 times – Newbie May 20 '16 at 09:08
-1

Did you tried

$('#form_te['+<?php echo  $id;?>+']').val()