CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2008
    Posts
    142

    what's wrong in this code?

    Hi

    I strucked with emails adding to the textarea. I used following code.

    Code:
       function addTo( emailAddr )
      {
        console.log('hi***'+document.emailForm.toAddr.value); // this prints empty  but it goes to else block.
        if ( document.emailForm.toAddr.value == ' ' )
          document.emailForm.toAddr.value = emailAddr;
        else
           // document.emailForm.toAddr.value = emailAddr;
           document.emailForm.toAddr.value += ', ' + emailAddr; 
      }
    what's wrong in the above code.
    Can any body give an Idea.

    Thanks in advance...

  2. #2
    Join Date
    Jun 2005
    Posts
    1,255

    Smile Re: what's wrong in this code?

    I used your code in the following page, and I see nothing wrong:
    Code:
    <html>
    <head>
    <script language=javascript>
    function addTo(emailAddr)
    {
        // console.log('hi***'+document.emailForm.toAddr.value); // this prints empty  but it goes to else block.
       if ( document.emailForm.toAddr.value == ' ' )
          document.emailForm.toAddr.value = emailAddr;
       else
          // document.emailForm.toAddr.value = emailAddr;
          document.emailForm.toAddr.value += ', ' + emailAddr; 
    }
    </script>
    </head>
    <body>
    <form name="emailForm" id="emailForm">
    <textarea name="toAddr" id= "toAddr" rows="5" cols="20">
    One
    Two
    </textarea>
    <input type="button" value="more" onclick="addTo('Three')">
    </form>
    </body>
    </html>

  3. #3
    Join Date
    Jan 2008
    Posts
    47

    Re: what's wrong in this code?

    code contains no error

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured