Don't see the error here

Discussion in 'Javascript' started by Fetty, Apr 11, 2005.

  1. Fetty

    Fetty Guest

    <script language="JavaScript">
    function copyComment(fieldNameVal,fieldTextVal){
    eval("document.Forms[0]." + fieldNameVal + ".value =" + fieldTextVal)
    }
    </Script>
     
    Fetty, Apr 11, 2005
    #1
    1. Advertising

  2. Fetty

    Lee Guest

    Fetty said:
    >
    ><script language="JavaScript">
    >function copyComment(fieldNameVal,fieldTextVal){
    >eval("document.Forms[0]." + fieldNameVal + ".value =" + fieldTextVal)
    >}
    ></Script>



    1. language="Javascript" is deprecated.
    2. Don't use eval() to reference form fields.
    3. There is no document.Forms attribute. It's "document.forms".


    Try:

    <script type="text/javascript">
    function copyComment(fieldNameVal,fieldTextVal){
    document.forms[0].elements[fieldNameVal].value = fieldTextVal;
    }
    </script>
     
    Lee, Apr 11, 2005
    #2
    1. Advertising

  3. Fetty

    Rob B Guest

    eval("document.F<------ try an 'f'

    Never mind, junk the whole thing....

    document.forms[0].elements[fieldNameVal].value = fieldTextVal;


    *** Sent via Developersdex http://www.developersdex.com ***
     
    Rob B, Apr 11, 2005
    #3
  4. Fetty

    Grant Wagner Guest

    "Fetty" <> wrote in message
    news:...
    > <script language="JavaScript">
    > function copyComment(fieldNameVal,fieldTextVal){
    > eval("document.Forms[0]." + fieldNameVal + ".value =" + fieldTextVal)
    > }
    > </Script>


    script tag language attribute deprecated, type attribute required.
    eval() not required. JavaScript is case-sensitive and the forms
    collection of the document object is lowercase.

    <script type="text/javascript">
    function copyComment(fieldNameVal, fieldTextVal)
    {
    document.forms[0].elements[fieldNameVal].value = fieldTextVal;
    }
    </script>

    --
    Grant Wagner <>
    comp.lang.javascript FAQ - http://jibbering.com/faq
     
    Grant Wagner, Apr 11, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nick Van Dyck
    Replies:
    1
    Views:
    422
    John Timney \(ASP.NET MVP\)
    Jan 9, 2005
  2. Flip
    Replies:
    3
    Views:
    979
    Tony Morris
    Feb 9, 2004
  3. Steve Kershaw
    Replies:
    1
    Views:
    364
    Brennan Stehling
    Sep 26, 2006
  4. Replies:
    1
    Views:
    140
  5. lorlarz
    Replies:
    82
    Views:
    659
    todd.levinson
    Sep 12, 2008
Loading...

Share This Page