Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用for循环和jQuery获取生成的输入元素_Jquery_Variables_Loops_Input - Fatal编程技术网

使用for循环和jQuery获取生成的输入元素

使用for循环和jQuery获取生成的输入元素,jquery,variables,loops,input,Jquery,Variables,Loops,Input,我有一个表单,您可以通过单击add按钮在第一步中用数据填充字段来添加字段。在第二步中,我希望显示这些数据,但我的循环不正确 这是原始表。通过单击add按钮,将生成一个带有新ID(item2,Ditem2…)的新tr标记 <table cellpadding="0" cellspacing="0" class="table" id="rp-article"> <tbody> <tr class="rowb"> &l

我有一个表单,您可以通过单击add按钮在第一步中用数据填充字段来添加字段。在第二步中,我希望显示这些数据,但我的循环不正确

这是原始表。通过单击add按钮,将生成一个带有新ID(item2,Ditem2…)的新tr标记

<table cellpadding="0" cellspacing="0" class="table" id="rp-article">
    <tbody>
        <tr class="rowb">
            <td class="col1 cell">
                <input disabled="disabled" id="count1" maxlength="10" name="count1" size="1"
                type="text" value="1" />
            </td>
            <td class="col2 cell">
                <input id="item1" maxlength="100" name="item1" size="15" type="text" value="Artikelnummer"
                />
            </td>
            <td class="col3 cell">
                <input id="Ditem1" maxlength="100" name="Ditem1" size="48" type="text"
                value="Beschreibung..." />
            </td>
            <td class="col4 cell">
                <input id="Aitem1" maxlength="100" name="Aitem1" size="5" type="text"
                value="Menge" />
            </td>
            <td class="col5 cell">
                <input id="Pitem1" maxlength="100" name="Pitem1" size="10" type="text"
                value="Preis" />
            </td>
            <td class="col6 cell">
                <select id="Ritem1" name="Ritem1">
                    <option>Retourengr&uuml;nde:</option>
                    <option>Ware falsch geliefert / falscher Inhalt</option>
                    <option>Ware falsch bestellt</option>
                    <option>Ware gef&auml;llt nicht</option>
                    <option>Ware passt nicht</option>
                    <option>Ware doppelt geliefert</option>
                    <option>Sonstiges</option>
                    <option>Ware defekt/besch&auml;digt/fehlerhaft</option>
                </select>
        </tr>
    </tbody>
</table>

Retourengrü;无损检测:
威尔·法尔希·格里弗特/法尔谢尔·因哈特
瓦法尔希·贝斯特尔特
Ware-gefä;尼希特律师事务所
货关
威尔·多佩尔特·格里弗特
桑斯蒂格斯
高级/高级和高级瓷器;迪格特/费勒哈夫特
现在,我想把它们全部抓取并显示在p标签中(n是tr数量的计数变量):

for(变量x=1;x=n;x++){
$('pt#u title2')。之后('p id='pt#u article'+x'>

'); $(“#pt_article”+x).html(“#”+x”); }
您的for循环不正确。请尝试以下方法:

for (var x = 1; x < n; x++) { // <--- note the < instead of =
  $('#pt_title2').after('<p id=#pt_article' + x + '></p>'); // you were missing a +
  $('#pt_article'+x).html('<b>#' + x + '</b>');  // same here
}

for(var x=1;x
for (var x = 1; x < n; x++) { // <--- note the < instead of =
  $('#pt_title2').after('<p id=#pt_article' + x + '></p>'); // you were missing a +
  $('#pt_article'+x).html('<b>#' + x + '</b>');  // same here
}

for(var x=1;xfor(var x=1;x=n;x++)
需要一个比较,您将n的值赋值给x的atm应该是:
for(var x=1;x==n;x++)
@m90这是一个很短的循环……应该是
x
。对。谢谢。但是这里有一个“意外标记”这个循环中有错误。不知道为什么。@AndersHolmström这是真的……你的循环
for(var x=1;x=n;x++)
需要比较,你将n的值赋给x的atm,应该是:
for(var x=1;x==n;x++)
@m90这是一个很短的循环……应该是
x
。对。谢谢。但是有一个问题此循环中出现“意外标记”错误。不知道原因。@AndersHolmström这是真的……太好了。如果我的答案正确,请接受并向上投票,以便其他人将来可以看到它。(我还需要声誉点数;))太好了。如果我的答案正确,请接受并向上投票,以便其他人将来可以看到它。(我还想要声誉积分;))