DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  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!



Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links