ยินดีต้อนรับคุณ, บุคคลทั่วไป กรุณา เข้าสู่ระบบ หรือ ลงทะเบียน

เข้าสู่ระบบด้วยชื่อผู้ใช้ รหัสผ่าน และระยะเวลาในเซสชั่น

ThaiSEOBoard.comพัฒนาเว็บไซต์Programmingสคริปไม่ทำงาน วานผู้รู้ช่วยชี้แนะด้วยค่ะ
หน้า: [1]   ลงล่าง
พิมพ์
ผู้เขียน หัวข้อ: สคริปไม่ทำงาน วานผู้รู้ช่วยชี้แนะด้วยค่ะ  (อ่าน 634 ครั้ง)
0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้
mija
Verified Seller
หัวหน้าแก๊งเสียว
*

พลังน้ำใจ: 107
ออฟไลน์ ออฟไลน์

กระทู้: 1,089



ดูรายละเอียด เว็บไซต์
« เมื่อ: 16 มิถุนายน 2010, 07:32:58 »

อ้างถึง
<script type="text/javascript" language="javascript">
         function calculate()
         {
            var productPrice =  document.getElementById('productPrice').value;
            var shipPrice  = document.getElementById('shipPrice').value;
            var totalPrice = document.getElementById('totalPrice');
            var calculateToThai = document.getElementById('calculateToThai');
            totalPrice.value = parseInt(productPrice)   parseInt(shipPrice);
            calculateToThai.value = parseInt(totalPrice.value) * 36;
            var fee = document.getElementById('fee').value;
            calculateToCost.value = parseInt(totalPrice1.value) * 5;
            var fe1e = document.getElementById('fee1').value;
            calculateToCost.value = parseInt(totalPrice2.value) * 5;
            totalPrice2.value = parseInt(fee)   parseInt(fee1);
   
         }
      </script>ค่าสินค้า
          <input type="text" id="productPrice"/>
  $<br/>
      ค่าขนส่งสินค้า 
       <input type="text" id="shipPrice"/>
      $<br/>
      คิดเป็นเงิน 
       <input type="text" id="totalPrice"/>
      $<br/>
      คิดเป็นเงินไทย
      <input type="text" id="calculateToThai"/>
      บาท
        <br/>
        บวกค่าธรรมเนียมธนาคารออนไลน์ 5%
        <br/>
        บวกค่าธรรมเนียมบัตรเครดิต 5%
 
<br/>
      ค่าใช้จ่ายทั้งสิ้นรวม <input type="text" id="toTalPrice2"/>
 
<br/>
      <input type="submit" value="Calculate" onClick="calculate()"/>

พยายามหันเขียนเองอยู่ แต่มันคำนวนแค่ช่วงแรก  Cry รบกวนด้วยนะคะ
บันทึกการเข้า

isawa
คนรักเสียว
*

พลังน้ำใจ: 10
ออฟไลน์ ออฟไลน์

กระทู้: 115



ดูรายละเอียด
« ตอบ #1 เมื่อ: 16 มิถุนายน 2010, 13:38:04 »

อ้างถึง
<script type="text/javascript" language="javascript">
         function calculate()
         {
            var productPrice =  document.getElementById('productPrice').value;
            var shipPrice  = document.getElementById('shipPrice').value;
            var totalPrice = document.getElementById('totalPrice');
            var calculateToThai = document.getElementById('calculateToThai');
            totalPrice.value = parseInt(productPrice)   parseInt(shipPrice);
            calculateToThai.value = parseInt(totalPrice.value) * 36;
            var fee = document.getElementById('fee').value;
            calculateToCost.value = parseInt(totalPrice1.value) * 5;
            var fe1e = document.getElementById('fee1').value;
            calculateToCost.value = parseInt(totalPrice2.value) * 5;
            totalPrice2.value = parseInt(fee)   parseInt(fee1);   
         }
      </script>ค่าสินค้า
          <input type="text" id="productPrice"/>
  $<br/>
      ค่าขนส่งสินค้า 
       <input type="text" id="shipPrice"/>
      $<br/>
      คิดเป็นเงิน 
       <input type="text" id="totalPrice"/>
      $<br/>
      คิดเป็นเงินไทย
      <input type="text" id="calculateToThai"/>
      บาท
        <br/>
        บวกค่าธรรมเนียมธนาคารออนไลน์ 5%
        <br/>
        บวกค่าธรรมเนียมบัตรเครดิต 5%
 
<br/>
      ค่าใช้จ่ายทั้งสิ้นรวม <input type="text" id="toTalPrice2"/>
 
<br/>
      <input type="submit" value="Calculate" onClick="calculate()"/>

พยายามหันเขียนเองอยู่ แต่มันคำนวนแค่ช่วงแรก  Cry รบกวนด้วยนะคะ


ลองดูตรงโค๊ดที่ไฮไลสีแดงดูครับ
บันทึกการเข้า

AsinLite สคริปดึงข้อมูล Asin Title Image จาก Amazon
playinw
Newbie
*

พลังน้ำใจ: 3
ออฟไลน์ ออฟไลน์

กระทู้: 17



ดูรายละเอียด
« ตอบ #2 เมื่อ: 16 มิถุนายน 2010, 14:05:47 »

อันนี้ id ของ element ก็ผิด Sad
ชื่อตัวแปรบางตัวไม่ได้ define แต่กลับเรียกใช้ :'(
Object บางอันไม่มีตัวตน  Lips Sealed
แถมอีกอย่างนะครับ ถึงคุณจะแก้ให้ใช้โค้ดนี้ได้ ก็ยังไม่ได้ตัวเลขที่ถูกต้องอยู่ดี

ให้ดูตรงค่าธรรมเนียม 5% คุณต้องเอาไปหารเอาจำนวนของเปอร์เซนมาบวก 5 แต่ในโค้ดคุณเอาไปคูณ 5 เฉยเลย
มันก็จะเท่ากับ ราคารวม คูณด้วยห้้า แล้วคูณด้วยห้า โอ้ว ค่าธรรมเนียมแพงกว่าสินค้าหลายเท่าตัวเลย T-T

ลองโค้ดที่ผมแก้ให้นี่ดูว่าคำนวนออกมาถูกไหม
http://demo.dig.in.th/cala.txt
« แก้ไขครั้งสุดท้าย: 16 มิถุนายน 2010, 14:29:53 โดย playinw » บันทึกการเข้า
mija
Verified Seller
หัวหน้าแก๊งเสียว
*

พลังน้ำใจ: 107
ออฟไลน์ ออฟไลน์

กระทู้: 1,089



ดูรายละเอียด เว็บไซต์
« ตอบ #3 เมื่อ: 16 มิถุนายน 2010, 14:54:23 »

 wanwan017 ขอบพระคุณมาก ๆ ค่ะ มือใหม่หัดเขียน อยากให้น้ำใจแต่ยังโพสไม่ถึง  wanwan031
บันทึกการเข้า

หน้า: [1]   ขึ้นบน
พิมพ์