Don't see the error here

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fetty

    #1

    Don't see the error here

    <script language="JavaS cript">
    function copyComment(fie ldNameVal,field TextVal){
    eval("document. Forms[0]." + fieldNameVal + ".value =" + fieldTextVal)
    }
    </Script>

  • Rob B

    #2
    Re: Don't see the error here


    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 ***

    Comment

    • Lee

      #3
      Re: Don't see the error here

      Fetty said:[color=blue]
      >
      ><script language="JavaS cript">
      >function copyComment(fie ldNameVal,field TextVal){
      >eval("document .Forms[0]." + fieldNameVal + ".value =" + fieldTextVal)
      >}
      ></Script>[/color]


      1. language="Javas cript" 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(fie ldNameVal,field TextVal){
      document.forms[0].elements[fieldNameVal].value = fieldTextVal;
      }
      </script>

      Comment

      • Grant Wagner

        #4
        Re: Don't see the error here

        "Fetty" <davef@helixpoi nt.com> wrote in message
        news:1113232255 .149284.214090@ f14g2000cwb.goo glegroups.com.. .[color=blue]
        > <script language="JavaS cript">
        > function copyComment(fie ldNameVal,field TextVal){
        > eval("document. Forms[0]." + fieldNameVal + ".value =" + fieldTextVal)
        > }
        > </Script>[/color]

        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(fie ldNameVal, fieldTextVal)
        {
        document.forms[0].elements[fieldNameVal].value = fieldTextVal;
        }
        </script>

        --
        Grant Wagner <gwagner@agrico reunited.com>
        comp.lang.javas cript FAQ - http://jibbering.com/faq


        Comment

        Working...