มันกดปุ่ม submit แล้วก็ clear ไม่ได้ ก็เลยติดว่าอาจมี error อยู่ ลองตรวจดูแล้วก็หาไม่เจอ ช่วยดูให้หน่อยนะคะ ขอบคุณค่ะ
<html>
<head>
<title>Thailand Vehical Noise Limit</title>
<script type="text/javascript">
function displayad()
{
var x1= parseFloat (document.getElementByld("x1").value);
var output1=";
var isValid = true;
isValid = validateForm(x1,isValid);
if(isValid){
if(x1<=95&&x1>0)
output1="Certified";
else
output1="Not certified.Your car noise limit should be less than 95 dB.";
document.getElementByld("output1").innerHTML=output1;
}
}
function cleared()
{
document.getElementByld("x1").innerHTML=";
document.getElementByld("output1").innerHTML=";
}
//var t=0;
function validateForm(x,isValid)
{
if(isValid==false)
return false;
if(x.length<=0 || (typeof x!="number") || !((x-0)==x))
{
alert("PLease put your number");
return false;
}
return true;
}
</script>
</head>
<body>
<body background="bg.jpg">
<font color="#000080">
<h1 align= 'center'>Thailand Vehical Noise Limit</h1>
<h3 align= 'center'>less than 2,200 kilogram and registered after 1st January 2014</h3>
</font>
<div id="input_div"style="width:1200px;">
<table>
<!--for row input1 data-->
<tr>
<td>
<b style="color:#4B0082">Put your number here</b>
</td>
<td>
<input id=x1" width="100%" height="400px" wrap="logical" type="text">
</input>
<i style="color:#4B0082">dB</i>
</td>
<tr>
<td>
<b style="color:#4B0082">Result  </b>
</td>
<td>
<b id="output1" style="color:#6495ED">
<i style="color:#4B0082"></i></b>
</td>
</tr>
</tr>
</table>
</div>
<hr/>
<!--for button area-->
<input style="margin-buttom:5px;font-family:verdana;" name="submit"
type="submit" value="Submit" onclick="displayad()">
<input style="margin-buttom:5px;font-family:verdana;" name="submit"
type="submit" value="Clear" onclick="cleared()">
<a href="project.html"><input type="submit"
name="name" value="Home"></a><p>
</div><br/>
</body>
</html>
source code นี้ผิดตรงไหนหรือปล่าวคะ?
Moderator: mindphp
-
- PHP Newbie
- โพสต์: 1
- ลงทะเบียนเมื่อ: 08/12/2015 12:42 pm
-
- PHP Hero Member
- โพสต์: 156
- ลงทะเบียนเมื่อ: 20/11/2015 9:05 am
Re: source code นี้ผิดตรงไหนหรือปล่าวคะ?
เขียน document.getElementById ผิด มันเลยไม่ออก
ประการตัวแปร แล้วใส่ ดับเบิ้ลโขดไม่ครบ
ประกาศ tag body เกิน
ประการตัวแปร แล้วใส่ ดับเบิ้ลโขดไม่ครบ
ประกาศ tag body เกิน
โค้ด: เลือกทั้งหมด
<html>
<head>
<title>Thailand Vehical Noise Limit</title>
<script type="text/javascript">
function displayad(){
var x1= parseFloat (document.getElementById("x1").value);
var output1= "";
var isValid = true;
isValid = validateForm(x1,isValid);
if(isValid){
if(x1<=95&&x1>0)
output1="Certified";
else
output1="Not certified.Your car noise limit should be less than 95 dB.";
document.getElementById("output1").innerHTML=output1;
}
}
function clears(){
document.getElementById('x1').value= '';
document.getElementById("output1").innerHTML="";
}
//var t=0;
function validateForm(x,isValid){
if(isValid==false)
return false;
if(x.length<=0 || (typeof x!="number") || !((x-0)==x)){
alert("PLease put your number");
return false;
}
return true;
}
</script>
</head>
<body background="bg.jpg">
<font color="#000080">
<h1 align= 'center'>Thailand Vehical Noise Limit</h1>
<h3 align= 'center'>less than 2,200 kilogram and registered after 1st January 2014
</h3>
</font>
<div id="input_div"style="width:1200px;">
<table>
<tr>
<td>
<b style="color:#4B0082">Put your number here</b>
</td>
<td>
<input id="x1" width="100%" height="400px" wrap="logical" type="text">
<i style="color:#4B0082">dB</i>
</td>
<tr>
<td>
<b style="color:#4B0082">Result  </b>
</td>
<td>
<b id="output1" style="color:#6495ED">
<i style="color:#4B0082"></i></b>
</td>
</tr>
</tr>
</table>
</div>
<hr/>
<!--for button area-->
<input style="margin-buttom:5px;font-family:verdana;" name="submit"
type="submit" value="Submit" onclick="displayad()">
<input id='x1' style="margin-buttom:5px;font-family:verdana;" name="x1"
type="submit" value="clear" onclick="clears();">
<a href="project.html"><input type="submit"
name="name" value="Home"></a><p>
</div><br/>
</body>
</html>
-
- Similar Topics
- ตอบกลับ
- แสดง
- โพสต์ล่าสุด
-
- 0 ตอบกลับ
- 2927 แสดง
-
โพสต์ล่าสุด โดย pataponnew
27/05/2021 5:10 pm
-
- 1 ตอบกลับ
- 2513 แสดง
-
โพสต์ล่าสุด โดย buay
03/06/2014 6:25 pm
-
-
โพสต์ใหม่ ขอไกด์ในการดึงข้อมูลจากหน้า Source code ลง Database หน่อยครับ
โดย chakirin.bfds » 08/01/2021 11:08 am » ใน Programming - C/C++ & java & Python - 6 ตอบกลับ
- 3584 แสดง
-
โพสต์ล่าสุด โดย chakirin.bfds
08/01/2021 7:44 pm
-
-
-
โพสต์ใหม่ วิธีเช็คเวอร์ชั่นบน Source Code Jooma ของเรา
โดย mindphp » 19/07/2016 5:01 am » ใน Joomla Developing Knowledge - 1 ตอบกลับ
- 1672 แสดง
-
โพสต์ล่าสุด โดย mindphp
19/07/2016 5:02 am
-
-
-
โพสต์ใหม่ การใช้งาน Bitbucket Source Code Version control อีกตัวหนึ่ง
โดย Zqkil » 07/06/2022 5:32 pm » ใน Microsoft Office Knowledge & line & Etc - 0 ตอบกลับ
- 1435 แสดง
-
โพสต์ล่าสุด โดย Zqkil
07/06/2022 5:32 pm
-
-
-
โพสต์ใหม่ การเชื่อมต่อ API ของ GitLab เพื่อดาวน์โหลดไฟล์ จาก Source Code Control Version
โดย tsukasaz » 31/03/2020 12:52 pm » ใน PHP Knowledge - 4 ตอบกลับ
- 6770 แสดง
-
โพสต์ล่าสุด โดย mindphp
04/03/2022 7:10 pm
-
-
-
โพสต์ใหม่ ตั้งค่าให้ Gitlab backup ไฟล์ source code ป้องการไฟล์หายระดับ server
โดย mindphp » 04/11/2021 3:03 pm » ใน Linux - Web Server - 1 ตอบกลับ
- 1000 แสดง
-
โพสต์ล่าสุด โดย mindphp
06/11/2021 2:05 pm
-
ผู้ใช้งานขณะนี้
สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 82