SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Get my greedy down dotJoon's Avatar
    Join Date
    Apr 2003
    Location
    daejeon, South Korea
    Posts
    2,209
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    I can't control a midDot in form value

    Code:
    <cfoutput>
    
    <form action='test.cfm' method='post'>
    <textarea name='myText'><cfif isDefined('form.myText')>#trim(form.myText)#<cfelse>a &#183;</cfif></textarea> 
    <input type='submit' value='submit'>
    </form>
    
    
    <cfif isDefined('form.myText')>
    <cfset myText=replace(form.myText,'a','my_a')>
    <cfset myText=replace(variables.myText,'&middot;','my_middot')>
    <cfset myText=replace(variables.myText,'&#183;','my_middot')>
    
    #variables.myText#
    </cfif>
    
    </cfoutput>
    The result of the code above is "my_a &#183;" But I like to get "my_a my_middot"


    This is very strange.
    Why does interpuct(middot) is not replaced to another word?
    How can I replace it to another word?
    Last edited by dotJoon; Feb 20, 2009 at 14:37.

  2. #2
    Get my greedy down dotJoon's Avatar
    Join Date
    Apr 2003
    Location
    daejeon, South Korea
    Posts
    2,209
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Code:
    code2
    
    <cfset myText='&#183;'>
    <cfset myText=replace(variables.myText,'&middot;','my_middot')>
    #variables.myText#
    The result of the code2 above becomes succesfully 'my_middot' instead of becoming failfully '&#183;'


    Code:
    code3
    
    <cfquery datasource='myDatasource' name='myDatabase'>
    select say
    from middot
    where id=1
    </cfquery>
    
    <cfset myText=myDatabase.say>
    <cfset myText=replace(variables.myText,'&middot;','my_middot')>
    #variables.myText#
    The result of the code3 above becomes failfully '&#183;' instead of becoming succesfully 'my_middot'

    In conclusion,
    it can become 'my_middot' when it starts from variables.myText.

    but
    it can't become 'my_middot' when it starts from form.myText.
    it can't become 'my_middot' when it starts from myDataBase.myText.

    I like to make 'my_middot' when it starts from form.myText OR myDatabase.myText.
    Last edited by dotJoon; Feb 20, 2009 at 15:41.

  3. #3
    Get my greedy down dotJoon's Avatar
    Join Date
    Apr 2003
    Location
    daejeon, South Korea
    Posts
    2,209
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <cffunction name="HtmlUnEditFormat" access="public" returntype="string" output="no" displayname="HtmlUnEditFormat" hint="Undo escaped characters"> 
          <cfargument name="str" type="string" required="Yes" /> 
          <cfscript> 
             var lEntities = ""; 
             var lEntitiesChars = "my_middot"; 
          </cfscript> 
          <cfreturn ReplaceList(arguments.str, lEntities, lEntitiesChars) /> 
    </cffunction> 
    
    <cfoutput> 
    
    <form action='test.cfm' method='post'> 
    <textarea name='myText'><cfif isDefined('form.myText')>#trim(form.myText)#<cfelse></cfif></textarea> 
    <input type='submit' value='submit'> 
    </form> 
    
    <cfif isDefined('form.myText')> 
    #htmlUnEditFormat(form.myText)# 
    </cfif> 
    </cfoutput>
    The code above still produces '' instead of 'my_middot'

    Do you see what's wrong in my applying CFfunction?

    (The CFfunction above is coming from http://www.coldfusionjedi.com/forums...3F5726B8607FD8 )


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
  •