Code not working

Discussion in 'Javascript' started by Michael_jd, Oct 4, 2004.

  1. Michael_jd

    Michael_jd Guest

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

    <title>ex 5</title>

    <script language="javascript">

    function Average()





    <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()>


    Internet Explorer says that the button object does not support the property or
    method. Please help.
    Michael_jd, Oct 4, 2004
    1. Advertisements

  2. Michael_jd

    Lee Guest

    Michael_jd said:
    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:
    Lee, Oct 4, 2004
    1. Advertisements

  3. Michael_jd

    Randy Webb Guest

    Rename the form or rename your function.
    Randy Webb, Oct 4, 2004
  4. In this particular instance, it's mandatory. Parentheses cannot appear in
    attribute values without quotation marks.


    Michael Winter, Oct 4, 2004
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.