Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Untitled Document</title>
- </head>
- <body>
- <h1 align="center" id="1"> Nhập và sắp xếp mảng </h1>
- Nhập phần tử thứ<input id="thu" name="pt" value="1" disabled="disabled" pattern="[0-9]*" type="text" /><p/>
- Giá trị <input id="gt" name="gt" pattern="[0-9]*" type="text" /><p/>
- <input type="button" name="them" value="thêm vào mảng" onclick="themvao()" />
- <input type="button" name="sapxep" value="sắp xếp" onclick="sapxep()" />
- <input type="button" name="timkiem" value="tìm Kiếm" onclick="seach()" /><p/>
- Mảng đã nhập <input id="hienthi" type="text" disabled="disabled" name="hienthi" />
- <script>
- a=new Array(100);
- function themvao()
- {
- document.getElementById("thu").value=eval(document.getElementById("thu").value)+1;
- gt=parseInt(document.getElementById("gt").value);
- a.push(gt);
- document.getElementById("hienthi").value=document.getElementById("hienthi").value+gt+" ";
- document.getElementById("gt").select();
- }
- function sapxep()
- {
- document.getElementById("hienthi").value="";
- a.sort()
- for( var i in a)
- {
- document.getElementById("hienthi").value=document.getElementById("hienthi").value+a[i]+" ";
- }
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement