アットウィキロゴ

あ2「」

<!DOCTYPE html>
 
<html lang="ja">
    <head>
        <meta charset="utf-8" />
        <title>rensyu</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="readfile.js"></script>
<script type="text/javascript" src="sample.js"></script>
</head>
<body onload="readfile()">
<input type="text" id="te" value="猫" size="20">
<input type="button" onclick="sample()" value="導入">
<p id="nc">表示</p>
</body>
</html>
 
 
 
function sample(){
 
var n=$("#te").val();
 
$("#nc").text(artist[n]);
 
}
 
 
var artist=new Array();
 
function readfile(){
 
    $.get("data.txt", function (data) {
 
        var s;
        var word = new Array();
        var str;
 
        word = data.split("</data>");
        for (s = 0; s < word.length; s++) {
            word[s] = word[s].replace("<data>", "");
        }
 
 
 
        for (s = 0; s < word.length; s++) {
            artist[s] = f(word[s]);
        }
 
 
 
 
    });
 
    function f(str){
        var strx;
        var p1, p2;
         p1 = str.indexOf("<artist>");
            p2 = str.indexOf("</artist>");
            strx = str.substring(p1, p2);
            strx = strx.replace("<artist>","");
        return strx;
    }
}
 
最終更新:2013年09月22日 19:14