I have multiple textbox from loop.
$qComposition = oci_parse($c1, "SELECT * FROM WA_SAC_TBL_COMPOSITION WHERE ACTIVE = 'Y' AND COMPOSITIONID != 'CM0001' ORDER BY LIST_ORDER ASC");
oci_execute($qComposition);
while($dComposition = oci_fetch_array($qComposition))
{
?>
<input type="text" class="inputText input<?php echo $dComposition['COMPOSITIONID']; ?>" placeholder="<?php echo $dComposition['COMPOSITION_NAME']; ?>" id="<?php echo $dComposition['COMPOSITIONID']; ?>" onkeypress="javascript:this.value=this.value.toUpperCase();" onkeyup="javascript:this.value=this.value.toUpperCase();" style="display: none;" disabled/>
<?php
}
Table WA_SAC_TBL_COMPOSITION
:
COMPOSITIONID | COMPOSITION_NAME
CM0001 | Status Sheet
CM0002 | Accessories Sheet
CM0003 | Box P/N
CM0004 | Pack Label P/N
CM0005 | Name Label
CM0006 | Warranty Card
CM0007 | DVD Part No
CM0008 | AC Code
And the result display on HTML to be
Then I have selected specific COMPOSITIONID
to be show. Table WA_SAC_TBL_PRODUCT_COMPOSITION
, here is the data:
COMPOSITIONID_FK PARTID_FK
CM0003 PA0001
CM0009 PA0001
CM0006 PA0001
CM0004 PA0001
CM0005 PA0001
CM0001 PA0001
As you can see CM0002
is not registered on table.
Here is JS to get selected COMPOSITIONID
$('.listScan, .inputText').hide(); //To hide all textbox
var lenComposition = jsonStr.composition.length;
for(var i=0; i<lenComposition; i++)
{
var composition = jsonStr.composition[i];
$('#'+composition).show(); //To show only choosed textbox
$('.input'+composition).attr('disabled', true);
}
var getTextboxID = $('input.inputText:eq(0)').attr('id');
alert(getTextboxID);
When I try to alert(getTextboxID)
, it show me CM0002
. As We know I didn't register it on choosed table. I know the JS get CM0002
from $qComposition
above.
But now I want JS get the ID only from choosed.
How to achieve that?