Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > RADIO TOTALS <!-- THREE STEPS TO INSTALL RADIO TOTALS: 1. Copy the coding into the HEAD of



 

RADIO TOTALS <!-- THREE STEPS TO INSTALL RADIO TOTALS: 1. Copy the coding into the HEAD of

 



Topic : 020278



โพสกระทู้ ( 1,008 )
บทความ ( 0 )



สถานะออฟไลน์
Twitter Facebook




<!-- THREE STEPS TO INSTALL RADIO TOTALS:

1. Copy the coding into the HEAD of your HTML document
2. Add the onLoad event handler into the BODY tag
3. Put the last coding into the BODY of your HTML document -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->

<HEAD>

<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Paul DeBrino ([email protected]) -->
<!-- Web Site: http://members.aol.com/irandd/ -->

<! >
<! >

<!-- Begin
//Define function to manipulate the form total per item selected/deselected:
function CheckChoice(whichbox) {
with (whichbox.form) {
//Handle differently, depending on type of input box.
if (whichbox.type == "radio") {
//First, back out the prior radio selection's price from the total:
hiddentotal.value = eval(hiddentotal.value) - eval(hiddenpriorradio.value);
//Then, save the current radio selection's price:
hiddenpriorradio.value = eval(whichbox.price);
//Now, apply the current radio selection's price to the total:
hiddentotal.value = eval(hiddentotal.value) + eval(whichbox.price);
}
else {
//If box was checked, accumulate the checkbox value as the form total,
//Otherwise, reduce the form total by the checkbox value:
if (whichbox.checked == false) {
hiddentotal.value = eval(hiddentotal.value) - eval(whichbox.value);
}
else {
hiddentotal.value = eval(hiddentotal.value) + eval(whichbox.value);
}
}
//Ensure the total never goes negative (some browsers allow radiobutton to be deselected):
if (hiddentotal.value < 0) {
InitForm();
}
//Now, return with formatted total:
return(formatCurrency(hiddentotal.value));
}
}
//Define function to format a value as currency:
function formatCurrency(num) {
<!-- Function courtesy of: Cyanide_7 ([email protected]) -->
<!-- Web Site: http://www7.ewebcity.com/cyanide7 -->
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num)) num = "0";
cents = Math.floor((num*100+0.5)%100);
num = Math.floor((num*100+0.5)/100).toString();
if(cents < 10) cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+num.substring(num.length-(4*i+3));
return ("$" + num + "." + cents);
}
//Define function to init the form on reload:
function InitForm() {
//Reset the displayed total on form:
document.myform.total.value='$0';
document.myform.hiddentotal.value=0;
document.myform.hiddenpriorradio.value=0;
document.myform2.total.value='$0';
document.myform2.hiddentotal.value=0;
document.myform2.hiddenpriorradio.value=0;
document.myform2.hiddenpriorradio.value=0;
//Set all checkboxes and radio buttons on form-1 to unchecked:
for (xx=0; xx < document.myform.elements.length; xx++) {
if (document.myform.elements[xx].type == 'checkbox' | document.myform.elements[xx].type == 'radio') {
document.myform.elements[xx].checked = false;
}
}
//Set all checkboxes and radio buttons on form-2 to unchecked:
for (xx=0; xx < document.myform2.elements.length; xx++) {
if (document.myform2.elements[xx].type == 'checkbox' | document.myform2.elements[xx].type == 'radio') {
document.myform2.elements[xx].checked = false;
}
}
}
// End -->
</script>

</HEAD>

<!-- STEP TWO: Insert the onLoad event handler into your BODY tag -->

<BODY onLoad="InitForm();" onreset="InitForm();">

<!-- STEP THREE: Copy this code into the BODY of your HTML document -->

<form method=POST name=myform>
Steak $15.25
<input type=checkbox name=Steak value=15.25 onClick="this.form.total.value=CheckChoice(this);">
Chicken $12.39
<input type=checkbox name=Chicken value=12.39 onClick="this.form.total.value=CheckChoice(this);">
Sushi $18.75
<input type=checkbox name=Sushi value=18.75 onClick="this.form.total.value=CheckChoice(this);">
<br>
<br>
<b>Prepare with this special sauce (extra charge -- only one selection allowed):</b>
<br>
None, thanks
<input type=radio name=Sauce value=none price=0.00 onClick="this.form.total.value=CheckChoice(this);">
Duck Sauce $10.99
<input type=radio name=Sauce value=duck price=10.99 onClick="this.form.total.value=CheckChoice(this);">
Ginger Sauce $5.00
<input type=radio name=Sauce value=ginger price=5.00 onClick="this.form.total.value=CheckChoice(this);">
Hot Sauce $1.50
<input type=radio name=Sauce value=hot price=1.50 onClick="this.form.total.value=CheckChoice(this);">
<br>
<br>
<br>
<input type=hidden name=hiddentotal value=0>
<input type=hidden name=hiddenpriorradio value=0>
Your total is: <input type=text name=total readonly>
<br>
<br>
(Note: Total can not be changed by the visitor.)
</font>
</form>
<hr width=100% noshade>
<form method=POST name=myform2>
Roasted Pig $10.00
<input type=checkbox name=Pig value=10.00 onClick="this.form.total.value=CheckChoice(this);">
Roasted Rat $17.49
<input type=checkbox name=Rat value=17.49 onClick="this.form.total.value=CheckChoice(this);">
Roasted Cat $3.50
<input type=checkbox name=Cat value=3.50 onClick="this.form.total.value=CheckChoice(this);">
<br>
<br>
<b>Prepare with this special seasoning (extra charge -- only one selection allowed):</b>
<br>
None, thanks
<input type=radio name=Season value=none price=0.00 onClick="this.form.total.value=CheckChoice(this);">
Liquid Nitrogen $17.50
<input type=radio name=Season value=nitrogen price=17.50 onClick="this.form.total.value=CheckChoice(this);">
Gun Powder $8.50
<input type=radio name=Season value=gunpowder price=8.50 onClick="this.form.total.value=CheckChoice(this);">
Vodka $4.00
<input type=radio name=Season value=vodka price=4.00 onClick="this.form.total.value=CheckChoice(this);">
<br>
<br>
<br>
<input type=hidden name=hiddentotal value=0>
<input type=hidden name=hiddenpriorradio value=0>
Your total is: <input type=text name=total readonly>
<br>
<br>
(Note: Total can not be changed by the visitor.)
</font>
</form>



<!-- Script Size: 6.37 KB -->


Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2 มิ.ย. 2551 00:39:44 By : arsachi View : 1394 Reply : 0
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : RADIO TOTALS &lt;!-- THREE STEPS TO INSTALL RADIO TOTALS: 1. Copy the coding into the HEAD of
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 03
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่