Hướng dẫn html code for question and answer box - mã html cho hộp câu hỏi và câu trả lời

Vì vậy, bạn muốn đố khách của bạn? Theo dõi mã JavaScript có thể giúp bạn dễ dàng tạo các biểu mẫu Q và A cho các trang web của bạn mà không cần sử dụng các tập lệnh CGI.

Mã sau sẽ cho phép bạn hiển thị hộp thoại cho biết câu trả lời đã chọn có đúng hay không. Bạn cũng có thể làm cho nó chuyển hướng khách truy cập sang một trang web khác tùy thuộc vào câu trả lời.

1. Đầu tiên, cắt và dán mã JavaScript sau vào trang web của bạn (gần với đầu trang ngay bên dưới thẻ cơ thể là một vị trí tốt):. First, cut-and-paste the following JavaScript code on to your web page (closer to the top of the page right below the BODY tag is a good location):

        type="text/javascript">

Liệt kê số 1: Mã JavaScript. Tải xuống chkanswr.htm (0,72 kb). : JavaScript code. Download chkanswr.htm (0.72 KB).

2. Chèn các thẻ HTML sau để tạo biểu mẫu đố của bạn (mã mẫu được hiển thị, sửa đổi khi cần thiết):. Insert the following HTML tags to create your quiz form (sample code shown, modify as necessary):

What is JavaScript?

      onSubmit="return checkAnswer(this,'B');"
>

& nbsp; & nbsp; // & nbsp; Go & nbsp; thông qua & nbsp; & nbsp; ; // & nbsp; & nbsp; var & nbsp; i & nbsp; = & nbsp; 0; & nbsp; & nbsp; for (; i
A. Another name for Java

& nbsp; & nbsp; // & nbsp; no & nbsp; ; cảnh báo ("làm ơn & nbsp; make & nbsp; a & nbsp; lựa chọn."); & nbsp; & nbsp; & nbsp; & nbsp; return & nbsp; false; & nbsp; & nbsp;}
B. A scripting language mostly for the web

& nbsp; & nbsp; // & nbsp; kiểm tra & nbs & nbsp; & nbsp; {& nbsp; & nbsp; & nbsp; & nbsp; alert ("'" & nbsp; & nbsp; & nbsp; & nbsp; if (urlright) & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;} & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;} & nbsp; & nbsp;}
C. When you use Java without compiling

& nbsp; & nbsp; // & nbsp; return & nbsp; "Sai & nbsp; & nbsp; // & nbsp; thay đổi & nbsp; này & nbsp; điểm & nbsp; to & nbsp; a & nbsp; hợp lệ & nbsp; cgi & nbsp; script & nbsp; } //->

& nbsp; & nbsp; // & nbsp; Go & nbsp; thông qua & nbsp; & nbsp; ; // & nbsp; & nbsp; var & nbsp; i & nbsp; = & nbsp; 0; & nbsp; & nbsp; for (; i : HTML code. Download quiz1.htm (0.37 KB).

& nbsp; & nbsp; // & nbsp; no & nbsp; ; cảnh báo ("làm ơn & nbsp; make & nbsp; a & nbsp; lựa chọn."); & nbsp; & nbsp; & nbsp; & nbsp; return & nbsp; false; & nbsp; & nbsp;}

& nbsp; & nbsp; // & nbsp; kiểm tra & nbs & nbsp; & nbsp; {& nbsp; & nbsp; & nbsp; & nbsp; alert ("'" & nbsp; & nbsp; & nbsp; & nbsp; if (urlright) & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;} & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;} & nbsp; & nbsp;}

& nbsp; & nbsp; // & nbsp; return & nbsp; "Sai & nbsp; & nbsp; // & nbsp; thay đổi & nbsp; này & nbsp; điểm & nbsp; to & nbsp; a & nbsp; hợp lệ & nbsp; cgi & nbsp; script & nbsp; } //->NAME tag must be "cc" and there should not be any other fields named "cc". The letter specified for the VALUE tag is the ID for the answer (start with "A" and keep incrementing as in the above sample. "X" is the answer ID in the following sample code):

Liệt kê số 1: Mã JavaScript. Tải xuống chkanswr.htm (0,72 kb).VALUE="X" NAME="cc">
Custom answer text

2. Chèn các thẻ HTML sau để tạo biểu mẫu đố của bạn (mã mẫu được hiển thị, sửa đổi khi cần thiết):onSubmit tag for the quiz form as shown below. "Y" is the letter ID for the correct answer. This letter must be assigned to one of the answers in the quiz form.

& nbsp; & nbsp; // & nbsp; return & nbsp; "Sai & nbsp; & nbsp; // & nbsp; thay đổi & nbsp; này & nbsp; điểm & nbsp; to & nbsp; a & nbsp; hợp lệ & nbsp; cgi & nbsp; script & nbsp; } //->
onSubmit="return checkAnswer(this,'Y');"
>

Liệt kê số 1: Mã JavaScript. Tải xuống chkanswr.htm (0,72 kb).correct.htm if the answer is correct or to wrong.htm otherwise. Note the two additional parameters specified in the "checkAnswer()" function:

What is JavaScript?

      onSubmit=
      "return checkAnswer(this, 'C', 
      'correct.htm', 'wrong.htm');"
>

& nbsp; & nbsp; // & nbsp; Go & nbsp; thông qua & nbsp; & nbsp; ; // & nbsp; & nbsp; var & nbsp; i & nbsp; = & nbsp; 0; & nbsp; & nbsp; for (; i
Another name for Java

& nbsp; & nbsp; // & nbsp; no & nbsp; ; cảnh báo ("làm ơn & nbsp; make & nbsp; a & nbsp; lựa chọn."); & nbsp; & nbsp; & nbsp; & nbsp; return & nbsp; false; & nbsp; & nbsp;}
When you use Java without compiling

& nbsp; & nbsp; // & nbsp; kiểm tra & nbs & nbsp; & nbsp; {& nbsp; & nbsp; & nbsp; & nbsp; alert ("'" & nbsp; & nbsp; & nbsp; & nbsp; if (urlright) & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;} & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;} & nbsp; & nbsp;}
A scripting language mostly for the web

& nbsp; & nbsp; // & nbsp; Go & nbsp; thông qua & nbsp; & nbsp; ; // & nbsp; & nbsp; var & nbsp; i & nbsp; = & nbsp; 0; & nbsp; & nbsp; for (; i : HTML code. Download quiz2.htm (0.39 KB).

& nbsp; & nbsp; // & nbsp; no & nbsp; ; cảnh báo ("làm ơn & nbsp; make & nbsp; a & nbsp; lựa chọn."); & nbsp; & nbsp; & nbsp; & nbsp; return & nbsp; false; & nbsp; & nbsp;}

& nbsp; & nbsp; // & nbsp; kiểm tra & nbs & nbsp; & nbsp; {& nbsp; & nbsp; & nbsp; & nbsp; alert ("'" & nbsp; & nbsp; & nbsp; & nbsp; if (urlright) & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;} & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;} & nbsp; & nbsp;}