Created
November 8, 2012 03:46
-
-
Save chikoski/4036650 to your computer and use it in GitHub Desktop.
テキスト入力欄に入力されたものを、配列に追加して、表示するプログラム.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="ja"> | |
<head> | |
<title>論プロテンプレート</title> | |
<meta charset="utf-8"> | |
<link rel="stylesheet" href="stylesheets/bootstrap.min.css"> | |
<style type="text/css"> | |
body { | |
padding-top: 60px; | |
padding-bottom: 40px; | |
} | |
.sidebar-nav { | |
padding: 9px 0; | |
} | |
textarea{ | |
width: 100%; | |
height: 10em; | |
} | |
</style> | |
<link rel="stylesheet" href="stylesheets/bootstrap-responsive.min.css"> | |
<!--[if lt IE 9]> | |
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> | |
<![endif]--> | |
</head> | |
<body> | |
<div class="navbar navbar-inverse navbar-fixed-top"> | |
<div class="navbar-inner"> | |
<div class="container"> | |
<a class="brand" href="#">Project Name</a> | |
</div> | |
</div> | |
</div> | |
<div class="container"> | |
<h1>論プロテンプレート</h1> | |
<p> | |
<input type="text" id="text_name"> | |
<input type="button" value="追加" onclick="addName()"> | |
</p> | |
<p id="output"> | |
</p> | |
</div> | |
<script> | |
var namelist = []; | |
function addName(){ | |
var input = document.getElementById("text_name"); | |
var output = document.getElementById("output"); | |
namelist.push(input.value);// 配列に要素を追加 | |
output.innerHTML = ""; | |
// 配列の要素を先頭から順番にすべて出力 | |
var i = 0; | |
while(i < namelist.length){ | |
output.innerHTML += namelist[i] + "<br>"; | |
i = i + 1; | |
} | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment