duanbo1659 2016-08-15 12:05
浏览 119

隐藏/显示表单部分

I have a table in which five fields have upload rows.Each time, I submit a row,the pages refreshes. However, I want to hide all the 4 rows, when the first submit button is clicked, then it should show the next row, and hide the previous row. This should continue till the last one. I have tried the following, but not working. ie all the rows are displaying. I need assitance on how to achieve this feat.

<script>
$("#othBtn1").click(function(){
 $("#oth2").show();
$("#oth1").hide();
$("#oth3").hide();
$("#oth4").hide();
$("#oth5").hide();
});
$("#othBtn2").click(function(){
 $("#oth3").show();
$("#oth1").hide();
$("#oth2").hide();
$("#oth4").hide();
$("#oth5").hide();
});
</script>

This will continue till the last button. See the HTML below:

<table width="96%" border="0" style="margin-top:10px;" align="left" id="tableRec"class="table table-bordered">
   <tr id="oth1">
    <th width="26%">Other Request (1):<small>  &nbsp;(Attachment Required) <i> Attach each other request per line</i></small></th>
    <td width="33%">Description:<input type="text" name="tdesc1" value="" placeholder="Enter the Description" class="form-control"></td><td width="12%">Amount:<input type="text" name="tamt1" value="" placeholder="Enter Amount and click Add to Request Button" class="form-control" /></td>
    <td>File(1):<input type="file" name="jfile1"/></td>
    <td width="29%"><input type="submit" name="othBtn1"  id="othBtn1" value="Add to Request" class="btn btn-success"  /> </td>
    </tr>
    <tr id="oth2">
    <th width="26%">Other Request (2):<small>  &nbsp;(Attachment Required) <i> Attach each other request per line</i></small></th>
    <td width="33%">Description:<input type="text" name="tdesc2" value="" placeholder="Enter the Description" class="form-control"></td><td width="12%">Amount:<input type="text" name="tamt2" value="" placeholder="Enter Amount and click Add to Request Button" class="form-control" /></td>
    <td>File(2):<input type="file" name="jfile2"/></td>
    <td width="29%"><input type="submit" name="othBtn2" id="othBtn2" value="Add to Request" class="btn btn-success" /></td>
    </tr>
    <tr id="oth3">
    <th width="26%">Other Request (3):<small>  &nbsp;(Attachment Required) <i> Attach each other request per line</i></small></th>
    <td width="33%">Description:<input type="text" name="tdesc3" value="" placeholder="Enter the Description" class="form-control"></td><td width="12%">Amount:<input type="text" name="tamt3" value="" placeholder="Enter Amount and click Add to Request Button" class="form-control" /></td>
    <td>File(3):<input type="file" name="jfile3"/></td>
    <td width="29%"><input type="submit" name="othBtn3" id="othBtn3" value="Add to Request" class="btn btn-success" /> </td>
    </tr>
    <tr id="oth4">
    <th width="26%">Other Request (4):<small>  &nbsp;(Attachment Required) <i> Attach each other request per line</i></small></th>
    <td width="33%">Description:<input type="text" name="tdesc4" value="" placeholder="Enter the Description" class="form-control"></td><td width="12%">Amount:<input type="text" name="tamt4" value="" placeholder="Enter Amount and click Add to Request Button" class="form-control" /></td>
    <td>File(4):<input type="file" name="jfile4"/></td>
    <td width="29%"><input type="submit" name="othBtn4"  id="othBtn4"value="Add to Request" class="btn btn-success" /> </td>
    </tr>
    <tr id="oth5">
    <th width="26%">Other Request (5):<small>  &nbsp;(Attachment Required) <i> Attach each other request per line</i></small></th>
    <td width="33%">Description:<input type="text" name="tdesc5" value="" placeholder="Enter the Description" class="form-control"></td><td width="12%">Amount:<input type="text" name="tamt5" value="" placeholder="Enter Amount and click Add to Request Button" class="form-control" /></td>
    <td>File(5):<input type="file" name="jfile5"/></td>
    <td width="29%"></td>
    </tr>
</table>
  • 写回答

2条回答 默认 最新

  • duanlu6268 2016-08-15 12:09
    关注

    You have a couple of issues.

    1. You are missing a opening bracket for your table <.

    2. You are missing the # in your selector.

    Change,

    table width="96%" border="0" style="margin-top:10px;" align="left" id="tableRec"class="table table-bordered">
    

    to,

    <table width="96%" border="0" style="margin-top:10px;" align="left" id="tableRec"class="table table-bordered">
    

    and change,

    $("#othBtn1").click(function() {
        $("#oth2").show();
        $("oth1").hide();
        $("oth3").hide();
        $("oth4").hide();
        $("oth5").hide();
    });
    $("#othBtn2").click(function() {
        $("#oth3").show();
        $("oth1").hide();
        $("oth2").hide();
        $("oth4").hide();
        $("oth5").hide();
    });
    

    to,

    $("#othBtn1").click(function() {
        $("#oth2").show();
        $("#oth1").hide();
        $("#oth3").hide();
        $("#oth4").hide();
        $("#oth5").hide();
    });
    
    $("#othBtn2").click(function() {
        $("#oth3").show();
        $("#oth1").hide();
        $("#oth2").hide();
        $("#oth4").hide();
        $("#oth5").hide();
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥100 iOS开发关于快捷指令截屏后如何将截屏(或从截屏中提取出的文本)回传给本应用并打开指定页面
  • ¥15 unity连接Sqlserver
  • ¥15 图中这种约束条件lingo该怎么表示出来
  • ¥15 VSCode里的Prettier如何实现等式赋值后的对齐效果?
  • ¥15 流式socket文件传输答疑
  • ¥20 keepalive配置业务服务双机单活的方法。业务服务一定是要双机单活的方式
  • ¥50 关于多次提交POST数据后,无法获取到POST数据参数的问题
  • ¥15 win10,这种情况怎么办
  • ¥15 如何在配置使用Prettier的VSCode中通过Better Align插件来对齐等式?(相关搜索:格式化)
  • ¥100 在连接内网VPN时,如何同时保持互联网连接