一個多行插入代碼

來源:互聯網
上載者:User

<script language="javascript">
//輸入指令碼內容
function Max()
{
var str = (document.send.vii.value).length
alert ('輸入值的長度為 ' + str + '位');
}

function changevalue()
{
if(document.all.vii.value == '' && document.all.vie.value != '')
{
document.all.vii.value = document.all.vie.value;
document.all.vie.value = '';
}
else if(document.all.vie.value == '' && document.all.vii.value != '')
{
document.all.vie.value = document.all.vii.value;
document.all.vii.value = '';
}
else if(document.all.vie.value != '' && document.all.vii.value != '')
{
var x = document.all.vie.value
var y = document.all.vii.value
document.all.vie.value = y;
document.all.vii.value = x;
}
}

</script>
<form name="send">
<input type=text value='' name="vii">
<input type=text value='' name="vie">
<input type="button" value="change" class="ButtonSave" onclick="javascript:changevalue();" id=button2 name=button2>
<input type="button" value="test" class="ButtonSave" onclick="javascript:Max();" id=button2 name=button2>

</form>

</br>
<script language="javascript">

<!--//一次性插入任意條記錄
//增加單條
      function setid(){
      var d = (document.all.N.value)
      str = '';

      d = ++(d)
       if(d>10)
             {
               alert('你真要把'+d+'行資料一次插入呀!\n可是系統最多隻充許10行.')

               return false;

             }

         for(i=1;i<=d;i++)

         str+=''+i+'. 註冊名:<input type=text name="name">密碼:<input type=password name="pass"><br>';
      window.tbid.innerHTML=str+'<br>';
      if (d <= 10)
         {
            document.all.N.value = d ;
            }
            else
            {document.all.N.value = 10}
     document.all.upcount.value = 1;
      document.all.scount.value = '';

      //alert(str + '\nN的值為:' + document.all.N.value);
      }

//批量增加
function batsetid()

{
str = ''
var d = document.all.upcount.value
if(d>10)
{
alert('你真要把'+d+'行資料一次插入呀!\n可是系統最多隻充許10行.')
return false;

}
for(i=1;i<=d;i++)

         str+=''+i+'. 註冊名:<input type=text name="name">密碼:<input type=password name="pass"><br>';
      window.tbid.innerHTML=str+'<br>';
     document.all.N.value = d ;
     document.all.upcount.value = 1;
     document.all.scount.value = '';
//alert(str + '\nN的值為:' + document.all.N.value);
      }
//刪除單條
function delline()
{
var d = document.all.N.value
str = '';
d = --(d)
       if (d == 0)
       {
       alert('你真的一行都不想要了?');
       //alert(d)
       document.all.scount.value ='';
       return false;
       }
       else if (d<0)
       {
       var x = document.all.scount.value;
       var y = document.all.scount.value - document.all.N.value;

       alert('要刪除的條數'+x+'多於現有條數'+y+'條');
       //alert(d);
       document.all.scount.value ='';
       return false;
       }
         for(i=1;i<=d;i++)

         str+=''+i+'. 註冊名:<input type=text name="name">密碼:<input type=password name="pass"><br>';
      window.tbid.innerHTML=str+'<br>';
      document.all.N.value = d ;
      document.all.scount.value = '';
}
//大量刪除
function batdel()

{
if(document.all.scount.value == '')
{
alert('請輸入要刪除的條數!')
document.all.scount.focus();
return false;
}
str = ''
var d = document.all.N.value
d = d - document.all.scount.value
       if (d == 0)
       {
       alert('你真的一行都不想要了?');
       //alert(d)
       document.all.scount.value ='';
       return false;
       }
       else if (d<0)
       {
       var x = document.all.scount.value;
       var y = document.all.scount.value - document.all.N.value;

       alert('要刪除的條數'+x+'多於現有條數'+y+'條');
       //alert(d);
       document.all.scount.value ='';
       return false;
       }
for(i=1;i<=d;i++)

         str+=''+i+'. 註冊名:<input type=text name="name">密碼:<input type=password name="pass"><br>';
      window.tbid.innerHTML=str+'<br>';
      document.all.pass.focus();
     document.all.N.value = d ;
     document.all.upcount.value = 1;
     document.all.scount.value = '';
//alert(str + '\nN的值為:' + document.all.N.value);
      }

 //-->
      </script>

      <script for="document" event="onkeydown" language="javascript">
//鍵盤操作定義,允許一路斷行符號進行到底.
if (event.keyCode==13){
        event.keyCode = 9;

}
if (event.keyCode == 187)
    {
    setid();
        }
        if (event.keyCode == 189)
    {
    delline();
        }
if (event.ctrlKey)
{
if(event.keyCode == 46)
    {
    document.all.scount.value = document.all.N.value - 1

    if (confirm('確定要刪除嗎?'))
    {batdel();}
    }
if(event.keyCode == 45)
{
document.all.upcount.value = 10
batsetid();
}
}

</script>
<body onload="document.all.pass.focus();">
<form name="myform" >
<select name="upcount" class="txtfld4" onChange="batsetid()">

                <option value="1">1 條</option>

                <option value="2">2 條</option>

                <option value="3">3 條</option>

                <option value="4">4 條</option>

                <option value="5">5 條</option>

                <option value="6">6 條</option>

                <option value="7">7 條</option>

                <option value="8">8 條</option>

                <option value="9">9 條</option>

                <option value="10">10 條</option>

              </select>

             減少數量 <input type="text" name="scount" value= "" size="3" maxlength="2"><input type="button" value="BatchDel-" class="ButtonSave" onclick="javascript:batdel();" id=button2 name=button2><input type="button" value="Add+" class="ButtonSave" onclick="javascript:setid();" id=button2 name=button2><input type="button" value="Del-" class="ButtonSave" onclick="javascript:delline();" id=button2 name=button2>
<TABLE>
<TR >
    <TD id="tbid" colspan="3" nowrap>使用者名稱<input type=text name="name">
    密碼<input type=password name="pass">

    <br></td>
</TR>
</TABLE>
當前數量:<INPUT TYPE="text" name="N" value="1">

</form>
+號增加行 -號減少行 Ctrl+Del刪除所有 Ctrl+ins加到最多
</body>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.