|
 |
|
รบกวนทีครับ ทำปุ๋ม Disable ไว้ แล้วจะหาย Disable ก็ต่อเมื่อกรอกข้อมูลทั้ง form ครบแล้ว |
|
 |
|
|
 |
 |
|
ไอเดีย น่าจะประมานใช้ javascript มาช่วยเช็คนะคะ แบบใช้ getElement มาเช็ค ถ้ามีค่าเป็นจริง ก็ให้ enable ปุ่มออกมาทำงานต่อ
สำหรับโค้ตคงต้องรอท่านอื่นนะค่า 
|
 |
 |
 |
 |
Date :
2011-03-29 10:49:11 |
By :
mzchewiize |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
<script type="text/javascript">
(function($){
$.fn.percentComplete = function(selector, color, size, button){
return this.each(function(){
var fieldCount = $(selector).length;
var completeCount = $(selector+'[value != ""][value != "select"]').length;
var percentComplete = Math.round((completeCount / fieldCount) * 100);
$(this).empty().append(percentComplete + "% Complete<br><div><div> </div></div>").children("div").css({"width": size, "border": "1px solid"+color}).children("div").css({"width": percentComplete+"%", "background-color":color});
if(percentComplete == '100'){
$(button).attr('disabled',false);
}else{
$(button).attr('disabled',true);
}
});
};
})(jQuery);
$("document").ready(function(){
$("#submit").attr('disabled',true);
$("#completion_meter").percentComplete(".required", "#FF0000", "200px", "#submit");
$(":input").blur(function(){
$("#completion_meter").percentComplete(".required", "#FF0000", "200px", "#submit");
});
});
</script>
</head>
<body>
<div id="container">
<div id="completion_meter"></div>
<br><br>
<form>
<div>First Name: <input class="required" id="first_name" name="first_name" type="text" value=""/></div>
<div>Last Name: <input class="required" id="last_name" name="first_name" type="text" value=""/></div>
<div>Email: <input class="required" id="email" name="email" type="text" value="" /></div>
<div>Birthday: <input class="required" id="Birthday" name="birthday" type="text" value="" /></div>
<div>Address: <input class="required" id="address" name="address" type="text" value="" /></div>
<div>Do you like Tech Crunch: <select class="required" id="tech_crunch"><option value="select">select</option><option value="yes">yes</option><option value="no">no</option></select></div>
<div>Description:<br><textarea rows="6" cols="40" class="required" name="description" id="description"></textarea></div>
<input type="submit" name="submit" id="submit" value="submit" />
</form>
</div>
</body>
</html>
เว็บตัวอย่าง http://forrst.com/posts/jQuery_Percent_Completed_Meter_a_jquery_plugin-Rv3
|
 |
 |
 |
 |
Date :
2011-03-29 11:44:21 |
By :
ไวยวิทย์ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ยังไม่ได้เลยครับ
|
 |
 |
 |
 |
Date :
2011-03-30 08:38:36 |
By :
coollyheart |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ยังไม่ได้นี่คือ ยังไม่ได้เขียน หรือ ยังเขียนไม่ได้
เอาโค้ดมาแป๊ะเลยครับ จะได้มีท่าน อื่น ๆ มาช่วยดูด้วย
|
ประวัติการแก้ไข 2011-03-30 08:44:14
 |
 |
 |
 |
Date :
2011-03-30 08:43:50 |
By :
ไวยวิทย์ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณครับ คุณ nico โค้ดที่ได้มาผมลองทำแล้วครับ แต่ว่ากรอกครบแล้ว button ยังไม่หาย Disable เลยครับ
|
 |
 |
 |
 |
Date :
2011-03-30 08:54:47 |
By :
coollyheart |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>jQuery Percent Completion Meter</title>
<style type="text/css">
#container {position:relative; width:990px; margin:0 auto;}
</style>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript">
(function($){
$.fn.percentComplete = function(selector, color, size, button){
return this.each(function(){
var fieldCount = $(selector).length;
var completeCount = $(selector+'[value != ""][value != "select"]').length;
var percentComplete = Math.round((completeCount / fieldCount) * 100);
$(this).empty().append(percentComplete + "% Complete<br><div><div> </div></div>").children("div").css({"width": size, "border": "1px solid"+color}).children("div").css({"width": percentComplete+"%", "background-color":color});
if(percentComplete == '100'){
$(button).attr('disabled',false);
}else{
$(button).attr('disabled',true);
}
});
};
})(jQuery);
$("document").ready(function(){
$("#submit").attr('disabled',true);
$("#completion_meter").percentComplete(".required", "#000000", "200px", "#submit");
$(":input").blur(function(){
$("#completion_meter").percentComplete(".required", "#000000", "200px", "#submit");
});
});
</script>
</head>
<body>
<div id="container">
<br><br>
<div id="completion_meter"></div>
<br><br>
<form>
<div>First Name: <input class="required" id="first_name" name="first_name" type="text" value=""/></div>
<div>Last Name: <input class="required" id="last_name" name="first_name" type="text" value=""/></div>
<div>Email: <input class="required" id="email" name="email" type="text" value="" /></div>
<div>Birthday: <input class="required" id="Birthday" name="birthday" type="text" value="" /></div>
<div>Address: <input class="required" id="address" name="address" type="text" value="" /></div>
<div>Do you like Tech Crunch: <select class="required" id="tech_crunch"><option value="select">select</option><option value="yes">yes</option><option value="no">no</option></select></div>
<div>Description:<br><textarea rows="6" cols="40" class="required" name="description" id="description"></textarea></div>
<input type="submit" name="submit" id="submit" value="submit" />
</form>
</div>
</body>
</html>
ผมลองกะ IE 6 และ Firefox 3.6.13 ได้ครับ
|
ประวัติการแก้ไข 2011-03-30 09:05:58
 |
 |
 |
 |
Date :
2011-03-30 09:03:04 |
By :
ไวยวิทย์ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|