<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8" />
<title>abc</title>
<script src="sample.js"></script>
<script src="jquery.js"></script>
</head>
<body onload="sample()">
<input type="button" value="検索" onClick="w()" />
<p id="memo"></p>
</body>
</html>
<?php
$strx=$_GET['stp'];
$fp = fopen("sample.txt", "w");
fwrite($fp,$strx);
fclose($fp);
?>
author = new Array();
title = new Array();
var number;
function sample(){
var str,file;
file = "sample.txt";
$.get(file, function (data) {
var str = data.split("</data>");
var s;
var memo, c1;
memo = "";
sx = 0;
for (s = 0; s < str.length; s++) {
c1 = str[s].replace("<data>", "");
sx = sx + 1;
title[sx] = catchword(c1, "title");
author[sx] = catchword(c1, "author");
}
number = sx;
$("#memo").html(number);
});
}
function w(){
var str,urlx;
str = "";
for (s = 1; s < number + 1; s++) {
str =str+ "<data>";
str =str+ "<author>";
str =str+ author[s];
str =str+ "</author>";
str =str+ "<title>";
str =str+ title[s];
str =str+ "</title>";
str =str+ "</data>";
}
urlx = "writefile.php?stp="+str;
$.get(urlx, function (data) {
$("#memo").html("ren");
});
}
function catchword(strp,word){
var p1,p2;
var w1, w2;
var strx;
w1 = "<" + word + ">";
w2 = "</" + word + ">";
p1=strp.indexOf(w1);
p2=strp.indexOf(w2);
strx = strp.substring(p1, p2);
strx=strx.replace(w1,"");
return strx;
}
最終更新:2013年12月16日 13:04