87,910
社区成员
发帖
与我相关
我的任务
分享
<form id="paymentItemFrom" onsubmit="return false;">
<div class="row">
@for(int i=1; i<4; i++)
{
<div class="col-sm-12 row-top">
<div class="input-group">
<span class="input-group-addon">X坐標(px)</span>
<input type="text" class="form-control empTypeahead" name="X"/>
</div>
</div>
<div class="col-sm-12 row-top">
<div class="input-group">
<span class="input-group-addon">Y坐標(px)</span>
<input type="text" class="form-control empTypeahead" name="Y"/>
</div>
</div>
<div class="col-sm-12 row-top">
<div class="input-group">
<span class="input-group-addon">寬度(px)</span>
<input type="text" class="form-control empTypeahead" name="Width" />
</div>
</div>
<div class="col-sm-12 row-top">
<div class="input-group">
<span class="input-group-addon">高度(px)</span>
<input type="text" class="form-control empTypeahead" name="Height"/>
</div>
</div>
}
</div>
</form>
var [X,Y,Width,Height]=[document.querySelectorAll("input[name='X']"),document.querySelectorAll("input[name='Y']"),document.querySelectorAll("input[name='Width']"),document.querySelectorAll("input[name='Height']")];
var arry=[];
[...X].forEach((item,index)=>{arry.push({X:item.value,Y:Y[index].value,Width:Width[index].value,Height:Height[index].value}) });