home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 February / CHIPCD_02_2002.iso / Internet / Macromedia ColdFusion Server 5 / coldfusion-50-win-us.exe / data1.cab / Examples / CFDOCS / snippets / insert.cfm < prev    next >
Encoding:
Text File  |  2001-06-13  |  1.5 KB  |  79 lines

  1. <!--- This example shows the use of Insert --->
  2.  
  3. <HTML>
  4.  
  5. <HEAD>
  6. <TITLE>
  7. Insert Example
  8. </TITLE>
  9. </HEAD>
  10.  
  11. <BASEFONT FACE="Arial, Helvetica" SIZE=2>
  12. <BODY  bgcolor="#FFFFD5">
  13.  
  14. <H3>Insert Example</H3>
  15.  
  16.  
  17. <CFIF IsDefined("form.myString")>
  18. <!--- if the position is longer than the length of
  19. the string, err --->
  20. <CFIF form.insertPosition GT Len(MyString)>
  21.  
  22.     <CFOUTPUT>
  23.     <P>This string only has #Len(MyString)#
  24.     characters; therefore, you cannot insert the substring
  25.     #form.mySubString# at position #form.insertPosition#.
  26.     </CFOUTPUT>
  27. <CFELSE>
  28.  
  29.     <CFOUTPUT>
  30.     <P>You inserted the substring #form.MySubstring# into the 
  31.     string #form.MyString#, resulting in the following 
  32.     string:<BR>#Insert(form.MySubString, form.myString, form.insertposition)#
  33.     </CFOUTPUT>
  34. </CFIF>
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42. </CFIF>
  43.  
  44.  
  45.  
  46. <P>This function will insert a substring into a
  47. string after a specified character position.
  48.  
  49. <FORM ACTION="insert.cfm" METHOD="POST">
  50. <P>Type a string
  51. <BR><INPUT TYPE="Text" NAME="MyString" VALUE="abcdefg">
  52. <P>And a substring to insert
  53. <BR><INPUT TYPE="Text" NAME="MySubString" VALUE="1234">
  54. <P>And the position at which to insert it
  55. <BR><SELECT NAME="InsertPosition">
  56.     <OPTION VALUE="1">1
  57.     <OPTION VALUE="2" SELECTED>2
  58.     <OPTION VALUE="3">3
  59.     <OPTION VALUE="4">4
  60.     <OPTION VALUE="5">5
  61.     <OPTION VALUE="6">6
  62.     <OPTION VALUE="7">7
  63.     <OPTION VALUE="8">8
  64.     <OPTION VALUE="9">9
  65.     <OPTION VALUE="10">10
  66. </SELECT>
  67.  
  68. <INPUT TYPE="Submit" NAME="show the example">
  69.  
  70.  
  71. </FORM>
  72.  
  73.  
  74.  
  75.  
  76. </BODY>
  77.  
  78. </HTML>       
  79.