忍者ブログ
JavaScript , Java , DOS , HTML(CSS) , JSP , SQL , VB , VBScript , ・・・etc などの覚書
×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

【Javascriptの場合】
■例
if( strName.match( /[^。-゚ァ-ンA-Za-z \s**ーー<>]+/ ) ) {
 漢字が入力されている
}

■説明

strName ⇒ 調べたい文字が入力された変数

・正規表現は、/[   ]+/ で囲む

・ ^ ⇒マッチしないという意味

・ 。-゚ ⇒ 半角カナの濁音などを含めた表現

・ ァ-ン ⇒ 全角カナ

・ A-Za-z ⇒ 全角、半角アルファベット

・ \s ⇒ スペース

その他は、そのまま記載


【JSP(JAVA)の場合】

■例
    Pattern searchPattern = Pattern.compile("[a-z A-Z 0-9 ァ-ン 。-゚ /**-ーー#]+");
    Matcher searchMatcher = searchPattern.matcher(name);
    if (!searchMatcher.find()) {
  漢字が入力されている
    }

■説明

name ⇒ 調べたい文字が入力された変数

・正規表現方法は、JavaScriptと同様

PR

エクスプローラ風ツリー例

WEB上でエクスプローラ風ツリーを表示させる。
以下使用方法

add(①,②,③,④,⑤,⑥,⑦,⑧,⑨,⑩)

①ユニークNo
②親のユニークNo
③表示される名称
④リンクURL
⑤タイトル
⑥表示されるURLのターゲット(ウィンドウ名)
⑦閉じた時のアイコンパス
⑧開いた時のアイコンパス
⑨表示時に開くかどうか(true/false)
id Number Unique identity number.
pid Number Number refering to the parent node. The value for the root node has to be -1.
name String Text label for the node.
url String Url for the node.
title String Title for the node.
target String Target for the node.
icon String Image file to use as the icon. Uses default if not specified.
iconOpen String Image file to use as the open icon. Uses default if not specified.
open Boolean Is the node open.


参考URL
http://youmos.com/news/dtree

download

オートコンプリート例

CGIを使用しないオートコンプリート
だいたい検索容量が100KBから200KB程度で動作する。
リストは、UTF-8にしており、datファイルとして保存。

【sample.dat】
var codeList = [
"100-0000 東京都千代田区以下に掲載がない場合",
"102-0072 東京都千代田区飯田橋",
"102-0082 東京都千代田区一番町",
"101-0032 東京都千代田区岩本町",
"101-0047 東京都千代田区内神田",
"100-0011 東京都千代田区内幸町",



];

【HTML】
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<title>Sample</title>
<script src="prototype.js" type="text/javascript"></script>
<script src="scriptaculous.js?load=effects,controls" type="text/javascript"></script>
<script src="codelist.dat" type="text/javascript"></script>
<script type="text/javascript">
window.onload = function() {
 new Autocompleter.Local("postcode", "addr", codeList, {minChars:6});
}
</script>
<style type="text/css">
#postcode {
 width:400px
}
#addr ul{
 margin-top:0px;
 border: 1px solid #aaa;
 list-style:none;
 padding:2px;
 background-color:#ffc;
}
#addr .selected {
 background-color: #ccf;
 cursor:default;
}
</style>
</head>
<body>
<p>郵便番号から入力してください。</p>
<form id="form01">
<input type="text" name="postcode" id="postcode" >
<div id="addr"></div>
</form>
</body>
</html>

download:オートコンプリート例

文字検索例

ページ内に記載された文字列から、指定の文字を検索する。
親ページから検索ウィンドウ(子ページ)を表示させ、子ページ内のスクリプトで検索を行う。
************************************

function findText(formObj)
{
 dst   = formObj.srchText.value;
 if (document.all)
 {
  if (formObj.iCase.checked) ignore = 4; else ignore = 0;
  src = window.opener.document.body.createTextRange();
  flag = src.findText(dst,1,ignore);
 }
 if (document.layers)
 {
  flag = window.opener.find(dst, formObj.iCase.checked, false);
 }
 if (flag) alert("発見"); else alert("見つかりません");
}

download:ページ内文字検索

ブログ内検索
カレンダー
04 2025/05 06
S M T W T F S
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

Copyright © [ moriBlog-memo ] All rights reserved.
Special Template : 忍者ブログ de テンプレート Special Thanks : 忍者ブログCommercial message : [PR]