推奨:ASPはXMLを使用して指定されたフォルダーをパッケージ化し、Webディレクトリにアップロードし、単独で開梱します'============================== 'File 1 'Pack.asp 'Change Cpathname This variable' will generate a DATA.XML file in the current directory' Upload DATA.XML and file 2 (install.asp) to the WEB root directory'Run install.asp unpacking' and manually delete the above twoファイル '=============================オプション説明
ASPオンラインQ&Aの例のコードはHTMLファイルであり、test.aspであり、コードは次のとおりです。
- <%@言語= vbscriptcodepage = 936%>
- <%
- ifsession(username)= then
- respons.write(<script> alert( 'ログインしてから操作を実行してください!'); window.location = 'login.asp?reurl = test.asp'; </script>)
- Response.End()
- endif
- %>
- <!doctypehtmlpublic - // w3c // dtdxhtml1.0transitional // enttp://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd>
- <htmlxmlns = http://www.w3.org/1999/xhtml>
- <head>
- <metahttp-equiv = content-typecontent = text/html; charset = gb2312/>
- <Title>シナリオQ&A </title>
- <styletype = text/css>
- <! -
- 体{}{
- フォントサイズ:12px;
- 色:#0066ff;
- }
- 入力{}{
- 境界線:1pxSolid#ffffff;
- バックグラウンドカラー:#eeeee;
- 左:1px;
- トップ:1px;
- 右:1px;
- 下:1px;
- クリップ:rect(10px、10px、10px、10px);
- マージン:1px;
- パディング:1px;
- }
- - >
- </style>
- </head>
- <ScriptLanguage = JavaScript>
- <! -
- functionchkform()
- {
- vare = document.frm;
- varit、flag、i;
- flag = false;
- for(i = 1; i <= 10; i ++)
- {
- variant = eval(e.question+i);
- variantlen = eval(e.question+i+.length);
- for(varj = 0; j <itlen; j ++)
- {
- varitchk = eval(e.question+i+[+j+]。チェック);
- if(itchk)
- {
- flag = true;
- 壊す;
- }
- if(!itchk && j == itlen-1)
- {
- flag = false;
- 壊す;
- }
- }
- if(!flag)
- {
- アラート(質問 +i +への回答を選択してください);
- ReturnFalse;
- }
- }
- if(!flag)
- {
- アラート(質問 +i +への回答を選択してください);
- eval(e.question+i+.focus());
- ReturnFalse;
- }
- returntrue;
- }
- - >
- </script>
- <body>
- <div> <strong>シナリオQ&A </strong> </div>
- <formname = frmaction = test_do.aspmethod = posponsubmit = return(chkform());>
- <p> <br/>
- 1。忘れられているとダウンしたヒロインの名前は何ですか? <br/>
- <label>
- <inputtype = radioname = question1value = a/>
- a。</label>
- lan <br/>
- <label>
- <inputtype = radioname = question1value = b/>
- b。</label>
- ジェニー<br/> <label>
- <inputtype = radioname = question1value = c/>
- c。</label>ルーシー</p>
- <p> 2.音楽の過去のバーの名前は何ですか? <br/>
- <label>
- <inputtype = radioname = question2value = a/>
- a。</label>
- 忘れられた<br/>
- <label>
- <inputtype = radioname = question2value = b/>
- b。</label>
- nv <br/>
- <label>
- <inputtype = radioname = question2value = c/>
- c。</label>
- 影のように</p>
- <p> 3。忘れられた写真の壁にはどんな写真がありますか? <br/>
- <label>
- <inputtype = radioname = question3value = a/>
- a。</label>
- 過去のヒロイン<br/>
- <label>
- <inputtype = radioname = question3value = b/>
- b。</label>
- 海のそばの景色<br/>
- <label>
- <inputtype = radioname = question3value = c/>
- c。</label>
- バーエクステリア</p>
- <p> 4.過去の音楽でヒロインが飲むワインの名前は何ですか? <br/>
- <label>
- <inputtype = radioname = question4value = a/>
- a。</label>
- 赤いピンクの美しさ<br/>
- <label>
- <inputtype = radioname = question4value = b/>
- b。</label>
- 7色の虹<br/>
- <label>
- <inputtype = radioname = question4value = c/>
- c。</label>
- コスタデルアズレ</p>
- <p> 5.忘却のNewVision Magazineのカバーキャラクターは誰ですか? <br/>
- <label>
- <inputtype = radioname = question5value = a/>
- a。</label> xuanbin <br/>
- <label>
- <inputtype = radioname = question5value = b/>
- b。</label>雨<br/>
- <label>
- <inputtype = radioname = question5value = c/>
- c。</label> Zhang Dongjian </p>
- <p> 6.音楽の過去のレコードの名前は何ですか? <br/>
- <label>
- <inputtype = radioname = question6value = a/>
- a。</label>
- 魅了された<br/>
- <label>
- <inputtype = radioname = question6value = b/>
- b。</label>
- 素晴らしい<br/>
- <label>
- <inputtype = radioname = question6value = c/>
- c。</label>
- 美しい</p>
- <p> 7.過去の音楽の壁に何が書かれていますか? <br/>
- <label>
- <inputtype = radioname = question7value = a/>
- a。</label>
- loveisbeautiful <br/>
- <label> <inputtype = radioname = question7value = b/>
- b。</label>
- truthisbeautiful <br/>
- <label> <inputtype = radioname = question7value = c/>
- c。</label>
- smileisbeautiful </p>
- <p> 8.過去の音楽のバーに何が置かれていますか? <br/>
- <label> <inputtype = radioname = question8value = a/>
- a。</label>
- 蓄音機<br/>
- <label> <inputtype = radioname = question8value = b/>
- b。</label>
- ラジオ<br/>
- <label> <inputtype = radioname = question8value = c/>
- c。</label>
- ビニールレコード</p>
- <p> 9.過去の音楽に対する男性の主人公の好みは何ですか? <br/>
- <label> <inputtype = radioname = question9value = a/>
- a。</label>
- 映画<br/>
- <label> <inputtype = radioname = question9value = b/>
- b。</label>
- 写真<br/>
- <label> <inputtype = radioname = question9value = c/>
- c。</label>
- タバコと音楽</p>
- <p> 10。クールダウンと不思議な主人公の趣味は何ですか? <br/>
- <label> <inputtype = radioname = question10value = a/>
- a。</label>
- 旅行<br/>
- <label> <inputtype = radioname = question10value = b/>
- b。</label>
- 写真<br/>
- <label> <inputtype = radioname = question10value = c/>
- c。</label>
- オンラインに行く</p>
- <p> <br/>
- <inputtype = submitname = submitvalue = submit/
- <br/>
- </p>
- </form>
- </body>
- </html>
以下は、バックグラウンドコードtest_do.aspです。コードは次のとおりです。
- <%@言語= vbscriptcodepage = 936%>
- <! - #includefile = conn.asp->
- <! - #includefile = function.asp->
- <%
- Response.CacheControl = no-cache
- Response.Expires = -1
- Response.ExpiresAbsolute = now()-1
- ifsession(username)= then
- respons.write(<script> alert( 'ログインしてから操作!'); window.location = 'login.asp?reurl = nv_scene_test.asp'; </script>)
- Response.End()
- endif
- '定義オプションの最高スコアは合計スコアです
- consttotalscore = 100
- Constitems = 10
- 'オプションスコアを定義します
- Dimresult(9)
- '最初の質問のスコアリング基準
- result(0)= a | 10 | _ | b | 0 | _ | c | 0
- '質問2のスコア基準
- result(1)= a | 0 | _ | b | 10 | _ | c | 0
- '3番目の質問スコア基準
- result(2)= a | 10 | _ | b | 0 | _ | c | 0
- '質問4スコア標準
- result(3)= a | 0 | _ | b | 0 | _ | c | 10
- '質問5スコア標準
- result(4)= a | 0 | _ | b | 0 | _ | c | 10
- '質問6スコア基準
- result(5)= a | 10 | _ | b | 0 | _ | c | 0
- '質問7スコア基準
- result(6)= a | 0 | _ | b | 10 | _ | c | 0
- '質問8スコア基準
- result(7)= a | 10 | _ | b | 0 | _ | c | 0
- '質問9スコア基準
- result(8)= a | 0 | _ | b | 0 | _ | c | 10
- '質問10thスコア基準
- result(9)= a | 0 | _ | b | 10 | _ | c | 0
- ''質問11スコア基準
- 'result(10)= a | 0 | _ | b | 0 | _ | c | 10
- '
- ''質問12スコア基準
- 'result(11)= a | 0 | _ | b | 10 | _ | c | 0
- '
- ''質問13スコア基準
- 'result(12)= a | 10 | _ | b | 0 | _ | c | 0
- '
- ''質問14thスコアリング基準
- 'result(13)= a | 0 | _ | b | 10 | _ | c | 0
- '
- ''質問15スコア基準
- 'result(14)= a | 0 | _ | b | 0 | _ | c | 10
- ifucase(request.servervariables(request_method))= postthen
- callchk_post()
- Dimi、Total、Selitem、Summary、Strdes、Strout
- 合計= 0
- fori = 0to(items-1)
- selval = trim(request.form(question&i+1))
- arritem = split(result(i)、| _ |)
- forj = 0toubound(arritem)
- ifselval = split(arritem(j)、|)(0)then
- TotalTotal = total+cint(split(arritem(j)、|)(1))
- selitemselitem = selitem&<li>質問&i+1&:&selval&</li>&vbcrlf
- endif
- 次
- 次
- summary = formatpercent(total/totalscore)
- if(合計/totalScore)> = 0.6then
- strdes = Remulty&Summary&<br>それを正常に渡しました
- それ以外
- strdes = result&summary&<br>悲しいことに、あなたの精度率は60%に達していません。もう一度やり直してください! <br> <ahref = test.asp '>オンラインQ&Aページに戻る>> </a>
- endif
- strout = youhaveselectedtheseItemsbelow:<br>&selitem&<br>合計:&合計&<br>正確性は:&要約です
- stroutstrout = strout&<br>&strdes
- str_sql = selectcount(1)fromuserinfowherememberid = '&session(id)&'
- rowcount = dataconn.execute(str_sql)(0)
- ifrowCount> 0then'Update個人情報が存在する場合
- str_sql = updateuserinfo
- str_sqlstr_sql = str_sql&setResult = '&formatnumber(total/totalscore、2)&'
- str_sqlstr_sql = str_sql&、ip = '&get_userip()&'
- str_sqlstr_sql = str_sql&、addtime = getDate()
- str_sqlstr_sql = str_sql&wherememberid = '&session(id)&'
- それ以外
- str_sql = insertintouserinfo(result、memberid、membername、ip)
- str_sqlstr_sql = str_sql&values( '&formatnumber(total/totalscore、2)&'、 '&session(id)&'、 '&session(username)&'、 '&get_userip()&')
- endif
- dataconn.execute(str_sql)
- endif
- %>
- <!doctypehtmlpublic - // w3c // dtdxhtml1.0transitional // enttp://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd>
- <htmlxmlns = http://www.w3.org/1999/xhtml>
- <head>
- <metahttp-equiv = content-typecontent = text/html; charset = gb2312/>
- <Title>オンラインQ&Aテスト結果</title>
- <styletype = text/css>
- <! -
- 体{
- フォントサイズ:12px;
- 色:#0066ff;
- }
- 入力{
- 境界線:1pxSolid#ffffff;
- バックグラウンドカラー:#eeeee;
- 左:1px;
- トップ:1px;
- 右:1px;
- 下:1px;
- クリップ:rect(10px、10px、10px、10px);
- マージン:1px;
- パディング:1px;
- }
- - >
- </style>
- </head>
- <body>
- <%response.write(strout)%>
- </body>
- </html>
共有:ASPエラーオブジェクトのヒントvbscriptには、スクリプトインタープリターがランタイムエラーを無視し、スクリプトコードの実行を継続するために、on error resumeの次のステートメントがあります。次に、スクリプトはERR.Numberプロパティの値を確認して、エラーが発生したかどうかを判断できます。エラーが発生した場合、ゼロ以外の値が返されます。 ASP 3.0では、エラーGOTO 0で使用してデフォルトを「ターンバック」することもできます