source code นี้ผิดตรงไหนหรือปล่าวคะ?

พูดคุยแลกเปลี่ยน ปัญหา การเขียน JavaScript เครื่องมือ AJAX Web 2.0 AJAX Framework jQuery และ Node.JS รวมถึง Framework Express ของ Node.JS ทำงานฝั่ง Server

Moderator: mindphp

murrayviolet
PHP Newbie
PHP Newbie
โพสต์: 1
ลงทะเบียนเมื่อ: 08/12/2015 12:42 pm

source code นี้ผิดตรงไหนหรือปล่าวคะ?

โพสต์ที่ยังไม่ได้อ่าน โดย murrayviolet »

มันกดปุ่ม 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 &nbsp</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()">

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;<a href="project.html"><input type="submit"
name="name" value="Home"></a><p>

</div><br/>

</body>
</html>
M031
PHP Hero Member
PHP Hero Member
โพสต์: 156
ลงทะเบียนเมื่อ: 20/11/2015 9:05 am

Re: source code นี้ผิดตรงไหนหรือปล่าวคะ?

โพสต์ที่ยังไม่ได้อ่าน โดย M031 »

เขียน document.getElementById ผิด มันเลยไม่ออก
ประการตัวแปร แล้วใส่ ดับเบิ้ลโขดไม่ครบ
ประกาศ 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 &nbsp</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();">

		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		&nbsp;&nbsp;&nbsp;&nbsp;<a href="project.html"><input type="submit"
		name="name" value="Home"></a><p>

	</div><br/>

</body>
</html>
ตอบกลับโพส
  • Similar Topics
    ตอบกลับ
    แสดง
    โพสต์ล่าสุด

ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 82