変更する必要がある td の値を持つ Entity Framework 生成テーブルがあります。ラジオボタンのグループを挿入する必要があるため、行ごとにこれを行う必要がありますが、ボタンの各行には一意の名前が必要です。
基本的に、「レート」の id を持つ td のテキストの値に基づいて、ボタンのグループにチェックされた値を設定し、値を取得した後に既存のテキストを削除する必要があります。
私のテーブルは次のようになります。
<table id="IndexTable">
<tr>
<th>CoffeeID </th>
<th>Degree </th>
<th>Weight </th>
<th>Profile </th>
<th>UsageInfo </th>
<th>Comments </th>
<th>AmbientTemp </th>
<th>Rating </th>
<th>WeightDeducted </th>
<th>Selected </th>
<th>ProfileID </th>
<th>ProfileStart </th>
</tr>
<tr>
<td>1 </td>
<td>1 </td>
<td>3 </td>
<td>9 </td>
<td>Filter Brew </td>
<td>Perfecto!! </td>
<td>55 </td>
<td id="Rating">4.25 </td>
<td>1 </td>
<td>4 </td>
<td>34 </td>
<td>1 </td>
</tr>
<tr>
<td>3 </td>
<td>15 </td>
<td>99 </td>
<td>87 </td>
<td>Espresso </td>
<td>WTF </td>
<td>99 </td>
<td id="Rating">4.5 </td>
<td>5 </td>
<td>3 </td>
<td>66 </td>
<td>4 </td>
</tr>
そして、私のスクリプトは次のとおりです。
$("tr").each(function() { //get all rows in table
var str = $("text[id=Rating]").val(); //assign text with matching id to str ---doesn't work
$("td").each(function() { //get all tds in current row
var newStr = ("#Rating").text; //assign text in td with id Rating to newStr ---- doesn't work
alert(newStr); // fires undefined for each td in table?
//This is where I want to insert radio buttons and assign the one with the value of the Rating td to checked.
});
});
これは最新のものです。私はこのサイト全体を見てきましたが、特定の行の特定の列から値を取得し、値を変更し、各行/列に対して繰り返すことを扱っていません。テーブル。私はデータベースのバックグラウンドから来ましたが、これは本当に単純で、非常にイライラします。