HTML – Javascript 應用

Posted: 十二月 29, 2007 in 技術相關
標籤:, ,

一般在撰寫 html 網頁表單時,會需要處理一些表單內容的檢查動作!

最簡單的方是就是運用 Javascript 技術來達成!

Javascript 的撰寫部分 一般都放在 網頁的 <head>…</head>

<script type="text/javascript"> 開頭 </script> 做結尾


function checkform()
		alert("Fill out name field please!");;
	else if(''){
		alert("Fill out e-mail field please!");;
	else if(document.form.suggestion.value==''){
		alert("Fill out suggesstion field please!");;

的 function 來定義函示Form 表單中開頭

<form action="mail.php" method="post" name="form1″ id="form1″ onSubmit="return checkform(this)">

onSubmit() 用來檢查 form 表單

如果 checkform() 傳回 false 則不處理表單的 action 動作(POST to mail.php), 反之則處理…

而 checkform(this) 這支 javascript 就是在做檢查是否表單中之必要欄位有被填寫…

其中 form 為表單名 name, email, suggestion 則為欄位名稱

如果要在點下 “submit" 按鈕時做檢查(觸發事件)則可以加入下面

<input type="submit" name="Submit2″ value="送出" onclick="disp_alert(checkformback())") />

其中 onclick 即為觸發動作

Javascript function -> disp_alart() 如下

function disp_alart(value){
	if(value) {
		alart("suggestion has been send !");
		//    do nothing

onclick 會依 checkformback()之回傳值丟入 disp_alart(BOOL value)中再做處理!

如果欄位檢查都填寫了 則傳入 TRUE 執行 disp_alart() 否則 do nothing !

  1. This piece of writing presents clear idea in support of the new viewers
    of blogging, that in fact how to do running a blog.

  2. Their unique personality is your guarantee fun-lover in you and find yourself an bodyguard.
    She is Fun, Compassionate, matter on Elfish escorts to yield you dependable ecstasy and satisfaction.

    Do men so pop, but after it was attacked by media and politics everyplace, easily, I ditched that thought process.
    On that point are some that Ukrainian girls
    are to the highest degree beautiful in the macrocosm.

  3. Move here 說道:

    Please let me know if you’re looking for a article author for your site. You have some really good posts and I believe I would be a good asset. If you ever want to take some of the load off, I’d absolutely love to write some content
    for your blog in exchange for a link back to mine.
    Please send me an e-mail if interested. Cheers!

  4. My brother recommended I might like this web site. He was once
    totally right. This put up actually made my day.
    You cann’t believe simply how much time I had spent for this information! Thank you!

  5. Lin 說道:

    First off I want to say awesome blog! I had a quick question in which I’d like to ask if you do not mind. I was interested to know how you center yourself and clear your thoughts prior to writing. I have had trouble clearing my mind in getting my thoughts out there. I truly do take pleasure in writing but it just seems like the first 10 to 15 minutes are generally lost just trying to figure out how to begin. Any ideas or hints? Thank you!

  6. certainly like your web site however you have to test the spelling on
    several of your posts. Many of them are rife with spelling problems and I find it very bothersome to inform
    the truth however I will surely come again again.

  7. This design is steller! You definitely know how to keep a reader
    amused. Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Fantastic job.
    I really enjoyed what you had to say, and more than that, how you presented it.
    Too cool!


在下方填入你的資料或按右方圖示以社群網站登入: 標誌

您的留言將使用 帳號。 登出 /  變更 )

Google+ photo

您的留言將使用 Google+ 帳號。 登出 /  變更 )

Twitter picture

您的留言將使用 Twitter 帳號。 登出 /  變更 )


您的留言將使用 Facebook 帳號。 登出 /  變更 )


連結到 %s