Help in placement of Javascript

Discussion in 'JavaScript' started by missladybee, May 28, 2007.

  1. #1
    I need help in the placement of the script below. I know absolutely nothing about javascript, so please explain in simple and easy to understand language where this would be place.

    :confused:

    <BODY OnLoad="clearAll()";>

    <FORM NAME=form1 METHOD=POST ACTION="http://www.my domainname.com/cgi-bin/cart.pl">
    ...
    </FORM>

    <SCRIPT LANGUAGE="JavaScript">
    function clearAll()
    {
    document.form1.multi-item1.checked = false;
    document.form1.multi-item2.checked = false;
    document.form1.multi-item3.checked = false;
    }
    </SCRIPT>
     
    missladybee, May 28, 2007 IP
  2. ansi

    ansi Well-Known Member

    Messages:
    1,483
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    100
    #2
    uhhh, it should be between the header tags. also the 'language' property is depreciated in favor of 'type'.

    example...

    
    <!DOCTYPE......>
    <html>
       <head>
          <title>my website</title>
          <meta...../>
          <script type="text/javascript">
             function clear_all()
             {
                 document.form1.multi-item1.checked = false; // assuming that this is correct 
                 document.form1.multi-item2.checked = false;
                 document.form1.multi-item3.checked = false;
             }
          </script>
       </head>
       <body onload="clear_all();">
          <form action.....>
             <input...... />
          </form>
       </body>
    </html>
    
    Code (markup):

    hope this helps you out some.

    for further reading, please see w3schools.com/jsref/
     
    ansi, May 28, 2007 IP
  3. coderlinks

    coderlinks Peon

    Messages:
    282
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hmm.. It think its ok if you place it in the body section also.
    And ansi is right about the language attribute. You should use the type attribute.

    ~
    Thomas
     
    coderlinks, May 29, 2007 IP