Created
March 12, 2014 10:46
-
-
Save furahaclothing/9504574 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
<script type="text/javascript"> | |
<!-- | |
function data_in(){ | |
//フォームデータ入力用変数 | |
var denpyou; | |
var kaisha; | |
var url; | |
url = new Array(); | |
//クロネコヤマト | |
url[1] = "http://jizen.kuronekoyamato.co.jp/jizen/servlet/crjz.b.NQ0010?id="; | |
//佐川急便 | |
url[2] = "http://k2k.sagawa-exp.co.jp/p/web/okurijosearch.do?okurijoNo="; | |
//日本郵便(ゆうパック・EXPACK・ポスパケット) | |
url[3] = "http://tracking.post.japanpost.jp/service/singleSearch.do?org.apache.struts.taglib.html.TOKEN=&searchKind=S002&locale=ja&SVID=&reqCodeNo1="; | |
//フォームデータを受け取る | |
if(document.form1.denpyou.value==""){ | |
alert("伝票番号が入力されていません。"); | |
} | |
else{ | |
denpyou=document.form1.denpyou.value; | |
//ラジオボタンの値を受け取る | |
for (i=0;i<document.form1.kaisha.length;i++){ | |
if (document.form1.kaisha[i].checked) | |
kaisha = document.form1.kaisha[i].value; | |
} | |
url = url[kaisha]; | |
//新しいウィンドウで検索結果を表示 | |
window.open(url+denpyou); | |
} | |
} | |
/* 半角数字チェック */ | |
function TextCheck() { | |
var str = document.form1.denpyou.value; | |
if( str.match( /[^0-9.-]+/ ) ) { | |
alert("半角数字、半角ハイフンで入力して下さい。"); | |
return 1; | |
} | |
return 0; | |
} | |
--> | |
</script> | |
<form id="form1" name="form1" method="post" action=""> | |
<br /> | |
<label for="denpyou">伝票番号 | |
<input name="denpyou" type="text" id="denpyou" value="" onblur="TextCheck();" /> | |
</label> | |
(半角数字、半角ハイフン) <br /> | |
<label for="kaisha">会社選択 | |
<input name="kaisha" type="radio" id="kaisha" value="1" checked /> | |
ヤマト運輸 | |
<input name="kaisha" type="radio" id="kaisha" value="2" /> | |
佐川急便 | |
<input name="kaisha" type="radio" id="kaisha" value="3" /> | |
ゆうパック・レターパック</label> | |
<br /> | |
<input name="button" type="submit" id="button" value="検索結果ページを開く" onClick="data_in();" /> | |
</form> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment