2014年4月28日 星期一

Lab 20 Hand code a form

Before you do this lab, you must understand what is CGI(Common Gateway Interface) and Form.
1. So please search the answer and post your opinion in your blog.
2. Hand code a HTML to edit an HTML so that the webpage can send a request to Google like http://maps.google.com/maps?q=24.9586,+121.24114 Use Form CGI that includes action, input, and submit. Try a few different coordinates. 3. If the input is not in the format of coordinates, display an error and ask the user to retry. For example, an incorrect input may look like 12.a2,21.22

===================================
CGI (Common Gateway Interface,共同閘道管制介面)不是一種語言,
而是一種象徵性的名稱。 
CGI程式可以用Perl、C++或是Visual Basic寫作而成。
CGI處處可見,留言板、聊天室與搜尋 引擎都是CGI程式可以寫成的。
CGI程式主要提供的是一種使用者與伺服器互動的一種管道。



Lab 20



程式碼:
<html>
<title>Lab 20</title>
<body>
<form action="http://maps.google.com/maps" method="get" name="f" onsubmit="return check()">
<input name="q" type="text"  />
<input name="send" type="submit" value="search" />
</form>
</body>
<script>
function check()
{     var floatReg =/^([+-]?)[1-9]\d*(\.\d*)?,([+-]?)[1-9]\d*(\.\d*)?$/;
         if(!floatReg.test(f.q.value)){
           
                alert("Incorrect format!!!");
            f.q.value="";
            document.f.q.focus();
            return false;        
         }
}
</script>                      
</html>

沒有留言:

張貼留言