PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > macromedia.dyna.html > What am I doing wrong?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
What am I doing wrong?

Réponse
 
LinkBack Outils de la discussion
Vieux 28/03/2008, 03h09   #1
goodridge_Winners
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut What am I doing wrong?

I have the calculator running smoothly on my 'Actual Webpage', but i wanted to
know how it actually worked. So i started a new document and threw together a
small 'form'.

The HTML code you see below will appear as a small box/table thing, with 2
checkboxes. when you click on the checkboxes, the total is meant to add up in
the 'total box'...but it doesnt seem to want to work.


So, could someone tell me what im doing wrong. Im not a javascript pro, so be
kind.
Thanks

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>GreyBox - Examples</title>

<script type="text/javascript">
var GB_ROOT_DIR ="Greybox/Greybox_v5_53/greybox/";
</script>

<script type="text/javascript"
src="Greybox/Greybox_v5_53/greybox/AJS.js"></script>
<script type="text/javascript"
src="Greybox/Greybox_v5_53/greybox/AJS_fx.js"></script>
<script type="text/javascript"
src="Greybox/Greybox_v5_53/greybox/gb_scripts.js"></script>
<link href="Greybox/Greybox_v5_53/greybox/gb_styles.css" rel="stylesheet"
type="text/css" media="all" />

</head>
<body>

<form method="post" name="orderform" enctype="text/plain">
<table border="0" bgcolor="#663F8F">
<tr bgcolor="#662F8F"><td colspan="2">
<p> <input type="checkbox" name="Item1" value="Item1_chosen" onclick="tally()"
/>
RM006
<p> <input type="checkbox" name="Item2" value="Item2_chosen" onclick="tally()"
/>
RM002</td></tr>
<tr>
<td><span class="style1"> Total
<input type="text" name="Total" value="$0" size="7">
</span></td>
</tr>
<tr>
<td><span class="style1"> Grand Total
<input type="text" name="GrandTotal" value="$0" size="8">
</span></td>
</tr>
</table>
</form>


<script language="javascript">

var Cost, Grand_Total;

function tally ()
{
cost = 0;
if (document.orderform.Item1.checked) { Cost = Cost + 17.00; }
if (document.orderform.Item2.checked) { Cost = Cost + 4.00: }

Cost = dollar(Cost);
Grand_Total = parseFloat(Cost)
Grand_Total = dollar(Grand_Total);

document.orderform.Total.value = "$" + Cost;
document.orderform.GrandTotal.value = "$" + Grand_Total;
}

function dollar (amount)
{
amount = parseInt(amount * 100);
amount = parseFloat(amount/100);
if (((amount) == Math.floor(amount)) && ((amount - Math.floor
(amount)) == 0))
{
amount = amount + ".00"
return amount;
}
if ( ((amount * 10) - Math.floor(amount * 10)) == 0)
{
amount = amount + "0";
return amount;
}
if ( ((amount * 100) - Math.floor(amount * 100)) == 0)
{
amount = amount;
return amount;
}
return amount;
}

//-->
</script>

</body>
</html>

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 23h57.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,08956 seconds with 9 queries