473,320 Members | 1,719 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,320 software developers and data experts.

Code not working

Some code I wrote is not working. Here it is:

<html>
<head>
<title>ex 5</title>

<script language="javascript">

function Average()
{
num_ein=window.document.Average.num1.value;
num_zwei=window.document.Average.num2.value;
num_drei=window.document.Average.num3.value;

alert(num_ein+num_zwei+num_drei);
}

</script>

</head>

<body>

<form name="Average">
<input type="text" name="num1"><br>
<input type="text" name="num2"><br>
<input type="text" name="num3"><br>
<input type="button" name="button1" value="Click for
Average" onClick=Average()>
</form>

</body>
</html>

Internet Explorer says that the button object does not support the property or
method. Please help.
Jul 23 '05 #1
3 1086
Michael_jd wrote:
Some code I wrote is not working. Here it is:
<--snip-->
function Average()
<--snip-->
<form name="Average">
<--snip-->
Internet Explorer says that the button object does not support the property or
method. Please help.


Rename the form or rename your function.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #2
Lee
Michael_jd said:

Some code I wrote is not working. Here it is:

<html>
<head>
<title>ex 5</title>

<script language="javascript">

function Average()
{
num_ein=window.document.Average.num1.value;
num_zwei=window.document.Average.num2.value;
num_drei=window.document.Average.num3.value;

alert(num_ein+num_zwei+num_drei);
}

</script>

</head>

<body>

<form name="Average">
<input type="text" name="num1"><br>
<input type="text" name="num2"><br>
<input type="text" name="num3"><br>
<input type="button" name="button1" value="Click for
Average" onClick=Average()>
</form>

</body>
</html>

Internet Explorer says that the button object does not support the property or
method. Please help.


1. Don't give a form and a function the same name. They share name space.
2. It's good practice to quote the value of the HTML onclick attribute.
3. The "language" attribute of the <script> tag is deprecated.
It's better to use: <script type="text/javascript">
4. Once you get to the point that your function is working, you'll find
that your alert is displaying the three string values concatinated,
rather than converted to numbers and summed. This link should help
you with that problem:

http://www.jibbering.com/faq/#FAQ4_21

Jul 23 '05 #3
On 3 Oct 2004 17:10:12 -0700, Lee <RE**************@cox.net> wrote:
Michael_jd said:
[snip]
<input type="button" name="button1" value="Click for Average"
onClick=Average()>


[snip]
2. It's good practice to quote the value of the HTML onclick attribute.


In this particular instance, it's mandatory. Parentheses cannot appear in
attribute values without quotation marks.

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

171
by: tshad | last post by:
I am just trying to decide whether to split my code and uses code behind. I did it with one of my pages and found it was quite a bit of trouble. I know that most people (and books and articles)...
17
by: tshad | last post by:
Many (if not most) have said that code-behind is best if working in teams - which does seem logical. How do you deal with the flow of the work? I have someone who is good at designing, but...
0
by: George2 | last post by:
Hello everyone, From the definition of working set, it is a subset of virtual pages resident in physical memory -- from book Windows Internals. It means working set could not be larger than...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.