douyi1982 2018-08-08 02:55
浏览 293

jQuery从循环选择获取文本框ID

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 enter image description here

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?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?