按钮单击添加动态文本框 [英] Add dynamic textbox by button click

查看:60
本文介绍了按钮单击添加动态文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.aspxpage包含19行。每行包含7个文本框一个下拉按钮我想通过单击+按钮显示该页面中的一行它会自动添加到页面..所以任何人都可以帮助我我新的网页,所以可以帮助编程... ...



我尝试过:



i不知道这个主题我写了19个文本框的代码我想减少代码。

i have one .aspxpage contains 19 rows.Every row contain 7 textboxes one dropdown button i want to show one row only in that page by clicking + button it will automatically added to page..So can any one help me i am new web pages so can pls help indetail coding...

What I have tried:

i have no idea about this topic i write the code for 19 textboxes i want to reduce the code.

推荐答案

<head runat="server">
    <title></title>
    <script>

        function addRow()
        {
            var tableRef = document.getElementById('myTable').getElementsByTagName('tbody')[0];

            // Insert a row in the table at the last row
            var newRow = tableRef.insertRow(tableRef.rows.length);

            // Insert a cell in the row at index 0
            var newCell = newRow.insertCell(0);

            var input = document.createElement('input');
            input.type = "text";
            // Append a text node to the cell
           
            newCell.appendChild(input);

            return false;
            
        }

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <button onclick="return addRow();">click me</button>
        <table id="myTable" border="1">
            <tr><td>Hello1</td></tr>
            <tr><td>Hello2</td></tr>
        </table>
    </div>
    </form>
</body>


这篇关于按钮单击添加动态文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆