Why this code doesn't work?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Why this code doesn't work?

  1. #1
    Larry Guest

    Why this code doesn't work?


    <script language="VBScript">
    Function ReplaceCR(patrn, replStr)
    Dim str, jobPostForm
    Set jobPostForm = document.forms("JobForm")
    str = jobPostForm.JD.value
    MsgBox(str)
    ReplaceCR = Replace(str, patrn, replStr)
    End Function

    MsgBox(ReplaceCR(chr(32), "<br><br>"))
    </script>

    I don't understand why this code doesn't work...
    *JD is a textareaI have in the form...
    I am trying to get the value of JD field, and replace all the space with
    <BR><BR>... for some reason this is not working...
    Thanks!

  2. #2
    Steve Cochran Guest

    Re: Why this code doesn't work?

    If an element is inside a form, you have to reference as a form element:

    jobpostform.elements("JD").value

    Try that and see if it works.

    steve

    "Larry" <larry@levelogic.com> wrote in message
    news:3974dd13$1@news.devx.com...
    >
    > <script language="VBScript">
    > Function ReplaceCR(patrn, replStr)
    > Dim str, jobPostForm
    > Set jobPostForm = document.forms("JobForm")
    > str = jobPostForm.JD.value
    > MsgBox(str)
    > ReplaceCR = Replace(str, patrn, replStr)
    > End Function
    >
    > MsgBox(ReplaceCR(chr(32), "<br><br>"))
    > </script>
    >
    > I don't understand why this code doesn't work...
    > *JD is a textareaI have in the form...
    > I am trying to get the value of JD field, and replace all the space with
    > <BR><BR>... for some reason this is not working...
    > Thanks!



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center