|
|
|
ต้องการในนำค่าใน span บันทึกลงฐานข้อมูลเขียน code อย่างไร |
|
|
|
|
|
|
|
ต้องการในนำค่าใน span ข้างล่างบันทึกลงฐานข้อมูลเขียน code อย่างไร
<span id="output1"></span>
<span id='comment1'></span>
Code (PHP)
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<html>
<head>
</head>
<script>
function compute(element) {
var run_50_m = Number(document.getElementById("run_50_m").value);
var run_50_m1 = Number(document.getElementById("run_50_m1").value);
var run_long = Number(document.getElementById("run_long").value);
var b_left = Number(document.getElementById("b_left").value);
var b_right = Number(document.getElementById("b_right").value);
var up_down = Number(document.getElementById("up_down").value);
var c_hand = Number(document.getElementById("c_hand").value);
var keep_thing = Number(document.getElementById("keep_thing").value);
var run_600_m = Number(document.getElementById("run_600_m").value);
var c_font = Number(document.getElementById("c_font").value);
console.log("run_50_m : "+ run_50_m);
console.log("run_long : "+ run_long);
console.log("b_left : "+ b_left);
console.log("b_right : "+ b_right);
var b1 = run_50_m ;
console.log("b1 : "+ b1);
document.getElementById("output1").innerHTML = b1;
if (b1 < 8.07){
document.getElementById("comment1").innerHTML = "very good";
}
if (b1 >= 8.08 && b1 <= 8.76) document.getElementById("comment1").innerHTML = "good";
if (b1 >= 8.77 && b1 <= 10.15) document.getElementById("comment1").innerHTML = "normal";
if (b1 >= 10.16 && b1 <= 10.84) document.getElementById("comment1").innerHTML = "bad";
if (b1 >= 10.85) document.getElementById("comment1").innerHTML = "very bad";
if (b1 >= 10.85) document.getElementById("comment1").innerHTML = "very bad";
// alert(document.getElementById("comment1").innerHTML);
document.getElementById(element).value = 'hi';
// document.getElementById("answer1").value = output;
//////////////////////////////////////////////////////////////////
var b0 = run_50_m1 ;
console.log("b0 : "+ b0);
document.getElementById("output11").innerHTML = b0;
if (b0 >173){
document.getElementById("comment11").innerHTML = "very good";
}
if (b0 >= 159 && b0 <= 172) document.getElementById("comment11").innerHTML = "good";
if (b0 >= 130 && b0 <= 158) document.getElementById("comment11").innerHTML = "normal";
if (b0 >= 116 && b0 <= 129) document.getElementById("comment11").innerHTML = "bad";
if (b0 <=115) document.getElementById("comment11").innerHTML = "very bad";
/////////////////////////////////
var b2 = b_left ;
console.log("b2 : "+ b2);
document.getElementById("output2").innerHTML = b2;
if (b2 > 173) document.getElementById("comment2").innerHTML = "very good";
if (b2 >= 159 && b2 <= 172) document.getElementById("comment2").innerHTML = "good";
if (b2 >= 130 && b2 <= 158) document.getElementById("comment2").innerHTML = "normal";
if (b2 >= 116 && b2 <= 129) document.getElementById("comment2").innerHTML = "bad";
// if (b2 <= 115) document.getElementById("comment2").innerHTML = "very bad";
//document.getElementById("answer2").value = output;
var b3 = b_left ;
console.log("b3 : "+ b3);
document.getElementById("output3").innerHTML = b3;
if (b3 > 21.3) document.getElementById("comment3").innerHTML = "very good";
if (b3 >= 18 && b3 <= 21.2) document.getElementById("comment3").innerHTML = "good";
if (b3 >= 11.2 && b3 <= 17.9) document.getElementById("comment3").innerHTML = "normal";
if (b3 >= 74.9 && b3 <= 11.1) document.getElementById("comment3").innerHTML = "bad";
if (b3 <= 7.8) document.getElementById("comment3").innerHTML = "very bad";
var b4 = b_right ;
console.log("b4 : "+ b4);
document.getElementById("output4").innerHTML = b4;
if (b4 > 21.3) document.getElementById("comment4").innerHTML = "very good";
if (b4 >= 18 && b4 <= 21.2) document.getElementById("comment4").innerHTML = "good";
if (b4 >= 11.2 && b4 <= 17.9) document.getElementById("comment4").innerHTML = "normal";
if (b4 >= 74.9 && b4 <= 11.1) document.getElementById("comment4").innerHTML = "bad";
if (b4 <= 7.8) document.getElementById("comment4").innerHTML = "very bad";
var ba1 = up_down;
console.log("ba1 : "+ ba1);
document.getElementById("output_up_down").innerHTML = ba1;
if (ba1 > 23) document.getElementById("comment_up_down").innerHTML = "very good";
if (ba1 >= 20 && ba1 <= 22) document.getElementById("comment_up_down").innerHTML = "good";
if (ba1 >= 13 && ba1 <= 19) document.getElementById("comment_up_down").innerHTML = "normal";
if (ba1 >= 10 && ba1 <= 12) document.getElementById("comment_up_down").innerHTML = "bad";
if (ba1 <= 9) document.getElementById("comment_up_down").innerHTML = "very bad";
var c_hand = c_hand;
console.log("c_hand : "+ c_hand);
document.getElementById("output_c_hand").innerHTML = c_hand;
if (c_hand > 21.34) document.getElementById("comment_c_hand").innerHTML = "very good";
if (c_hand >= 16.07 && c_hand <= 21.33) document.getElementById("comment_c_hand").innerHTML = "good";
if (c_hand >= 5.50 && c_hand <= 16.06) document.getElementById("comment_c_hand").innerHTML = "normal";
if (c_hand >= 0.23 && c_hand <= 5.49) document.getElementById("comment_c_hand").innerHTML = "bad";
if (c_hand <= 0.22) document.getElementById("comment_c_hand").innerHTML = "very bad";
var keep_thing = keep_thing;
console.log("keep_thing : "+ keep_thing);
document.getElementById("output_keep_thing").innerHTML = keep_thing;
if (keep_thing < 10.75) document.getElementById("comment_keep_thing").innerHTML = "very good";
if (keep_thing >= 10.76 && keep_thing <= 11.71) document.getElementById("comment_keep_thing").innerHTML = "good";
if (keep_thing >= 11.72 && keep_thing <= 13.64) document.getElementById("comment_keep_thing").innerHTML = "normal";
if (keep_thing >= 13.65 && keep_thing <= 14.60) document.getElementById("comment_keep_thing").innerHTML = "bad";
if (keep_thing >= 14.61) document.getElementById("comment_keep_thing").innerHTML = "very bad";
var run_600_m = run_600_m;
console.log("run_600_m : "+ run_600_m);
document.getElementById("output_run_600_m").innerHTML = run_600_m;
if (run_600_m < 2.20) document.getElementById("comment_run_600_m").innerHTML = "very good";
if (run_600_m >= 2.21 && run_600_m <= 2.40) document.getElementById("comment_run_600_m").innerHTML = "good";
if (run_600_m >= 2.41 && run_600_m <= 3.20) document.getElementById("comment_run_600_m").innerHTML = "normal";
if (run_600_m >= 3.21 && run_600_m <= 3.40) document.getElementById("comment_run_600_m").innerHTML = "bad";
if (run_600_m >= 3.41) document.getElementById("comment_run_600_m").innerHTML = "very bad";
var c_font = c_font;
console.log("c_font : "+ c_font);
document.getElementById("output_c_font").innerHTML = c_font;
if (c_font > 8.5) document.getElementById("comment_c_font").innerHTML = "very good";
if (c_font >= 6.5 && c_font <= 8) document.getElementById("comment_c_font").innerHTML = "good";
if (c_font >= 1 && c_font <= 6) document.getElementById("comment_c_font").innerHTML = "normal";
if (c_font >= -1 && c_font <= -0.5) document.getElementById("comment_c_font").innerHTML = "bad";
if (c_font <= -1.5) document.getElementById("comment_c_font").innerHTML = "very bad";
}
var HttPRequest = false;
function doCallAjax(Mode) {
HttPRequest = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
HttPRequest = new XMLHttpRequest();
if (HttPRequest.overrideMimeType) {
HttPRequest.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
HttPRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
HttPRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!HttPRequest) {
alert('Cannot create XMLHTTP instance');
return false;
}
var url = 'save.php';
var pmeters = "&tname=" + encodeURI( document.getElementById("txtName").value ) +
//"&trun_50_m=" + encodeURI( document.getElementById("run_50_m").value ) +
"&b1=" + encodeURI(document.getElementById("comment1").innerHTML) +
"&toutput1=" + encodeURI( document.getElementById("output1").value ) +
"&tMode=" + Mode;
HttPRequest.open('POST',url,true);
HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
HttPRequest.setRequestHeader("Content-length", pmeters.length);
HttPRequest.setRequestHeader("Connection", "close");
HttPRequest.send(pmeters);
HttPRequest.onreadystatechange = function()
{
if(HttPRequest.readyState == 3) // Loading Request
{
document.getElementById("mySpan").innerHTML = "Now is Loading...";
}
if(HttPRequest.readyState == 4) // Return Request
{
document.getElementById("mySpan").innerHTML = HttPRequest.responseText;
// document.getElementById("txtCustomerID").value = '';
document.getElementById("txtName").value = '';
document.getElementById("output1").value = '';
document.getElementById("comment1").value = '';
// document.getElementById("txtBudget").value = '';
// document.getElementById("txtUsed").value = '';
}
}
}
</script>
Tag : PHP, MySQL, HTML/CSS, JavaScript
|
ประวัติการแก้ไข 2016-11-28 09:17:41 2016-11-28 13:56:51 2016-11-28 13:58:20
|
|
|
|
|
Date :
2016-11-28 09:14:26 |
By :
mininovaa |
View :
1061 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เปลี่ยนจาก
Code (PHP)
<input type="hidden" name="name" value="<? echo $name?>">
เป็น
Code (PHP)
<input type="hidden" name="name" value="<?php echo $name?>">
ลองดูครับ
|
ประวัติการแก้ไข 2016-11-28 09:41:43
|
|
|
|
Date :
2016-11-28 09:40:47 |
By :
poy |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<input type="hidden" name="name" value="<? echo $name?>">
หรือจะแก้เป็น
<input type="hidden" name="name" value="<?=$name?>">
|
|
|
|
|
Date :
2016-11-28 11:33:05 |
By :
apisitp |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|