首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

帮忙写个js,该怎么处理

2014-01-12 
帮忙写个js废话不多说,先上代码html xmlnshttp://www.w3.org/1999/xhtmlheadmeta http-equivCon

帮忙写个js
废话不多说,先上代码


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
    <script language="javascript">
    function moveText() {
            var input = document.createElement('input');
            input.name = "txtRsv";
            input.type = 'text';
            input.style.width = '70%';
            input.style.marginTop = '5px';
            input.style.marginLeft = '10px';
            document.getElementById("RsvDiv").appendChild(input);
            var input1 = document.createElement('input');
            input1.type = 'button';
            input1.value = '删除';
            document.getElementById("RsvDiv").appendChild(input1);
            var input2 = document.createElement('input');
            input2.type = 'button';
            input2.value = '移至未解决';
            document.getElementById("RsvDiv").appendChild(input2);
        }
    </script>
<body>
    <table style="width: 100%;">
        <tr>
            <td class="auto-style8" colspan="6" valign="top">
                    <div style="margin-top: 10px; margin-left: 60px">
                        <a style="float: left">已解决:</a>
                        <div id="RsvDiv" style="margin-left: 50px; width: 960px;">
                            <input name="txtRsv" type="text" style="margin-top: 5px; margin-left: 10px; width: 70%;" />&nbsp;
                            <input id="Button1" type="button" value="删除" />&nbsp;<input id="Button7" type="button" value="移至未解决" /><br />
                        </div>
                    </div>
                    <br />
                    <div style="margin-top: 10px; margin-left: 60px;">
                        <a style="float: left">未解决:</a>
                        <div id="UnRsvDiv" style="margin-left: 50px; width: 960px;">
                            <input name="txtUnResv" type="text" value="" style="margin-top: 5px; margin-left: 10px; width: 70%;" />&nbsp; 
                            <input id="Button5" type="button" value="删除" />&nbsp;<input id="Button6" type="button" value="移至已解决" onclick="moveText()" />
                        <br />
                        </div>
                    </div>


                </td>
        </tr>
    </table>
</body>
</html>


右下角那个按钮有效果,先试试……
但是那个选中行的value我不会获取,所以帮忙实现下按钮的功能:能删除选中行,能移动选中行,说的不是很清楚,但是相信你们懂的
[解决办法]
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
    <title></title>
</head>
    <script language="javascript">
        function moveItem(btn, ok) {
            var targetID = ok ? 'RsvDiv' : 'UnRsvDiv';
            document.getElementById(targetID).appendChild(btn.parentNode);
            btn.onclick = function () { moveItem(this, !ok); }
            btn.value = ok ? '移至未解决' : '移至已解决';
        }
        function DelItem(btn) {var item = btn.parentNode, p = item.parentNode;p.removeChild(item);}
    </script>
<body>
    <table style="width: 100%;">
        <tr>
            <td class="auto-style8" colspan="6" valign="top">
                    <div style="margin-top: 10px; margin-left: 60px">
                        <a style="float: left">已解决:</a>
                        <div id="RsvDiv" style="margin-left: 50px; width: 960px;">
                        <div>
                            <input name="txtRsv" type="text" style="margin-top: 5px; margin-left: 10px; width: 70%;" value="1" />&nbsp;
                            <input id="Button1" type="button" value="删除" onclick="DelItem(this)" />&nbsp;<input id="Button7" type="button" value="移至未解决" onclick="moveItem(this)" />
                            </div><div>
                            <input name="txtRsv" type="text" style="margin-top: 5px; margin-left: 10px; width: 70%;" value="2" />&nbsp;
                            <input id="Button9" type="button" value="删除" onclick="DelItem(this)" />&nbsp;<input id="Button10" type="button" value="移至未解决" onclick="moveItem(this)" />
                            </div><div>
                            <input name="txtRsv" type="text" style="margin-top: 5px; margin-left: 10px; width: 70%;" value="3" />&nbsp;
                            <input id="Button11" type="button" value="删除" onclick="DelItem(this)" />&nbsp;<input id="Button12" type="button" value="移至未解决" onclick="moveItem(this)" />


                            </div><div>
                            <input name="txtRsv" type="text" style="margin-top: 5px; margin-left: 10px; width: 70%;" value="4" />&nbsp;
                            <input id="Button13" type="button" value="删除" onclick="DelItem(this)" />&nbsp;<input id="Button14" type="button" value="移至未解决" onclick="moveItem(this)" />
                            </div>
                        </div>
                    </div>
                    <br />
                    <div style="margin-top: 10px; margin-left: 60px;">
                        <a style="float: left">未解决:</a>
                        <div id="UnRsvDiv" style="margin-left: 50px; width: 960px;">
                           <div> 
                           <input name="txtUnResv" type="text" style="margin-top: 5px; margin-left: 10px; width: 70%;" value="5" />&nbsp; 
                            <input id="Button5" type="button" value="删除" onclick="DelItem(this)" />&nbsp;<input id="Button6" type="button" value="移至已解决" onclick="moveItem(this,true)" />
                       </div><div> 
                           <input name="txtUnResv" type="text" style="margin-top: 5px; margin-left: 10px; width: 70%;" value="6" />&nbsp; 
                            <input id="Button2" type="button" value="删除" onclick="DelItem(this)" />&nbsp;<input id="Button3" type="button" value="移至已解决" onclick="moveItem(this,true)" />
                       </div><div> 
                           <input name="txtUnResv" type="text" style="margin-top: 5px; margin-left: 10px; width: 70%;" value="7" />&nbsp; 
                            <input id="Button4" type="button" value="删除" onclick="DelItem(this)" />&nbsp;<input id="Button8" type="button" value="移至已解决" onclick="moveItem(this,true)" />
                       </div>
                        </div>
                    </div>
                </td>
        </tr>
    </table>
</body>
</html>

热点排行