ZBLOG

for (var i = 1; i

要实现你所描述的修改,你可以按照以下方式修改代码:

for (var i = 1; i <= 12; i++) {
    var groupIndex = Math.ceil(i / 4); // 计算当前i所在的组索引
    title_val += `
        <tr>
            <td class="qdd_value">${client_selfloop(groupIndex, i)}</td>
        </tr>`;
}

function client_selfloop(groupIndex, currentIndex) {
    var startRange = (groupIndex - 1) * 4 + 1; // 计算当前组的起始值
    var endRange = groupIndex * 4; // 计算当前组的结束值

    return `
        LANE1: <select id='client_set_selfloop1${currentIndex}' style='width:115px'><option selected='selected' value=0>关闭</option> <option value=1>打开</option> </select> <button onclick="set_client_selfloop(1, ${currentIndex})" style='margin-left:-3px;margin-top:3px;'>设置</button><br>
        LANE2: <select id='client_set_selfloop2${currentIndex}' style='width:115px'><option selected='selected' value=0>关闭</option> <option value=1>打开</option> </select> <button onclick="set_client_selfloop(1, ${currentIndex})" style='margin-left:-3px;margin-top:3px;'>设置</button><br>
        LANE3: <select id='client_set_selfloop3${currentIndex}' style='width:115px'><option selected='selected' value=0>关闭</option> <option value=1>打开</option> </select>
        <button onclick="set_client_selfloop(1, ${currentIndex})" style='margin-left:-3px;margin-top:3px;'>设置</button><br>
        LANE4: <select id='client_set_selfloop4${currentIndex}' style='width:115px'><option selected='selected' value=0>关闭</option> <option value=1>打开</option> </select>
        <button onclick="set_client_selfloop(1, ${currentIndex})" style='margin-left:-3px;margin-top:3px;'>设置</button><br>
    `;
}

这样修改后,每个组的起始索引会根据当前组索引进行计算,并传递给client_selfloop函数作为参数。在函数内部,你可以使用这个起始值和结束值来生成相应的内容。请注意,groupIndex表示当前i所在的组索引,而currentIndex则表示当前循环迭代的索引值。


内容由零声教学AI助手提供,问题来源于学员提问

本站部分文章来源于网络,版权归原作者所有,如有侵权请联系站长删除。
转载请注明出处:https://golang.0voice.com/?id=16792

分享:
扫描分享到社交APP
上一篇
下一篇
发表列表
游客 游客
此处应有掌声~
评论列表

还没有评论,快来说点什么吧~

联系我们

在线咨询: 点击这里给我发消息

微信号:3007537140

上班时间: 10:30-22:30

关注我们
x

注册

已经有帐号?