我正在使用具有文本字段作爲單元格的Yii CGridView。我用CHtml :: textField顯示文本字段。現在我想更新同一行中另一個單元格的值更改中的單元格。同一行中的文本字段的ID具有相同的編號。例如ProjectMBookGrid_length_163和ProjectMBookGrid_quantity_163。在更改ProjectMBookGrid_length_163值時,我想更改ProjectMBookGrid_quantity_163中的值,更改ProjectMBookGrid_length_164值時,我想要更改ProjectMBookGrid_quantity_164中的值。 JS小提琴在https://jsfiddle.net/7ykdkgaw/根據同一行中另一個文本字段中的值更改文本字段的值
<table>
<tr><td><input type="text" id="ProjectMBookGrid_length_163" name="ProjectMBookGrid[length_163]" value="5" style="text-align: right" class="gridfield"></td><td><input type="text" id="ProjectMBookGrid_quantity_163" name="ProjectMBookGrid[quantity_163]" value="3" style="text-align: right" class="gridfield"></td></tr>
<tr><td><input type="text" id="ProjectMBookGrid_length_162" name="ProjectMBookGrid[length_162]" value="3" style="text-align: right" class="gridfield"></td><td><input type="text" id="ProjectMBookGrid_quantity_162" name="ProjectMBookGrid[quantity_162]" value="3" style="text-align: right" class="gridfield"></td></tr>
</table>
請小提琴 –
@ P.Frank加js小提琴 – user1690835