By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,541 Members | 1,105 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,541 IT Pros & Developers. It's quick & easy.

This will not help inspite of corrections. Object expected

P: 9
this program is supposed to give the user the ability to enter numbers
in cents and tell you how many dollars you have. PLease anybody can
tell me what's wrong.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Cents to Dollars</title>
<script type="text/javascript">
<!-- HIDE FROM INCOMPATIBLE BROWSERS
function calcCents (){
var cents = document.money.cents.value;
var dollars = 0;
var dollars = cents / 100;
var change = cents % 100;
if (change != 00)
window.alert("The number of cents you entered is equal to $" +
dollars + ".00");
else
window.alert("The number of cents you entered is equal to $" +
dollars);

}
// STOP HIDING FROM INCOMPATIBLE BROWSERS -->
</script>
</head>
<body>
<form name="money" action="">
<p>Cents: <input type="text" name="cents" /><br />
<input type="button" value="Cents to Dollars" onclick="calcCents();"
/></p>
</form>
</body>
</html>
Nov 14 '06 #1
Share this Question
Share on Google+
2 Replies


10K+
P: 13,264
this program is supposed to give the user the ability to enter numbers
in cents and tell you how many dollars you have. PLease anybody can
tell me what's wrong.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Cents to Dollars</title>
<script type="text/javascript">
<!-- HIDE FROM INCOMPATIBLE BROWSERS
function calcCents (){
var cents = document.money.cents.value;
var dollars = 0;
var dollars = cents / 100;
var change = cents % 100;
if (change != 00)
window.alert("The number of cents you entered is equal to $" +
dollars + ".00");
else
window.alert("The number of cents you entered is equal to $" +
dollars);

}
// STOP HIDING FROM INCOMPATIBLE BROWSERS -->
</script>
</head>
<body>
<form name="money" action="">
<p>Cents: <input type="text" name="cents" /><br />
<input type="button" value="Cents to Dollars" onclick="calcCents();"
/></p>
</form>
</body>
</html>
Where do you have a problem with this? It should work perfectly from what I see.

And oh, you really should have asked this in the javascript forum.
Nov 14 '06 #2

P: 25
Expand|Select|Wrap|Line Numbers
  1.  
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  3. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. <html>
  5. <head>
  6. <title>Cents to Dollars</title>
  7. <script type="text/javascript">
  8. <!-- HIDE FROM INCOMPATIBLE BROWSERS
  9. function calcCents (){
  10. var cents = document.money.cents.value;
  11. var dollars = 0;
  12. var dollars = cents / 100;
  13. var change = cents % 100;
  14. if (change != 0)
  15. window.alert("The number of cents you entered is equal to $" +
  16. dollars);
  17. else
  18. window.alert("The number of cents you entered is equal to $" +
  19. dollars + ".00");
  20. }
  21. // STOP HIDING FROM INCOMPATIBLE BROWSERS -->
  22. </script>
  23. </head>
  24. <body>
  25. <form name="money" action="">
  26. <p>Cents: <input type="text" name="cents" /><br />
  27. <input type="button" value="Cents to Dollars" onclick="calcCents();"
  28. /></p>
  29. </form>
  30. </body>
  31. </html>
  32.  
you just had to interchange the alerts
it works absolutely fine then
Nov 15 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.