473,396 Members | 2,108 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

This will not work. "OBJECT EXPECTED"

9
Originally Posted by 511475
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. been working on it two weeks

<!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
4 2003
ronverdonk
4,258 Expert 4TB
Don't know that much about it, but don't you need an id='cents' tag in your input statement?

Ronald :cool:
Nov 14 '06 #2
pronerd
392 Expert 256MB
Don't know that much about it, but don't you need an id='cents' tag in your input statement?

Ronald :cool:
ronverdonk has it. The code is looking for a tag with an ID of "cents", but there are not any. So the object that it should be getting is null.
Nov 15 '06 #3
AricC
1,892 Expert 1GB
The code you posted seems to be working somewhat fine for me. You may want to get rid of the extra .00 after say you put in 150 it will give you 1.5.00
Nov 15 '06 #4
hai 511475

just change your code from

var cents = document.money.cents.value;

to

var cents = document.forms.money.cents.value;
(or)
var cents = window.money.cents.value;
Nov 17 '06 #5

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

Similar topics

24
by: Hung Jung Lu | last post by:
Hi, Does anybody know where this term comes from? "First-class object" means "something passable as an argument in a function call", but I fail to see the connection with "object class" or...
4
by: Armel Asselin | last post by:
Hello, I'm working on a Javascript interpreter; when I execute this code I cannot figure out why the inner "c" function returns the input widget as "this"... could someone tell ?? <input...
2
by: brazilnut52 | last post by:
I am going to outline the steps I go through to produce the problem. Hopefully this will help you understand the problem better I have created a simple COM DLL in .NET by using the COM class...
1
by: Gidrazas | last post by:
Hello I'm trying to generate DataSet from Sybase ASA 9 database. I'll use it in Crystal Reports. But when i'm trying to drag table from Server Explorer as written in...
4
by: Daniel | last post by:
Hi, I have problem to get the control id and set its visible to true/false(mean show/hide). here is my code: <%@ Control Language="vb" AutoEventWireup="false" Codebehind="ucNavbar.ascx.vb"...
7
by: Robin Tucker | last post by:
Hiya, I'm using mshtml and the web browser control to embed an OLE object in my ..NET application. What I want to do is get a reference to the "object" embedded therein: The HTML looks...
4
by: lars.uffmann | last post by:
Hey everyone! I am (still) working on a project that I took over from former students, so don't blame me for the criminal approach on coding *g* The problem I have is fairly easy and while I...
16
by: Steve Chapel | last post by:
When I load the page <https://bugzilla.mozilla.org/attachment.cgi?id=237739with Internet Explorer 7 RC 1, I get the error "Object Expected" at line 174. When I click on the button, I also get the...
2
by: thj | last post by:
Hi. I've got this form that I'm trying to validate: <form id="periodForm" action="" method="post"> <p> Periode: <input id="startDate" name="startDate" type="text" size="7" value="<%=...
2
by: bednarz.thomas | last post by:
I have the following business Object(s): public class ParentObject { public ParentObject(string somestring) { ...- } ....
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.