home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 1999 April / APC443.iso / features / grpware / coldfus / coldfusi.exe / data1.cab / Documentation / snippets / mid.cfm < prev    next >
Encoding:
Text File  |  1998-10-08  |  1.5 KB  |  52 lines

  1. <!---  This example shows the use of Mid --->
  2. <HTML>
  3. <HEAD>
  4. <TITLE>Mid Example</TITLE>
  5. </HEAD>
  6.  
  7. <BODY bgcolor=silver>
  8. <H3>Mid Example</H3>
  9.  
  10. <CFIF IsDefined("Form.MyText")>
  11. <!--- if len is 0, then err --->
  12.     <CFIF Len(form.myText) is not 0>
  13.         <CFIF Len(form.myText) LTE form.RemoveChars>
  14.         <P>Your string <CFOUTPUT>#form.myText#</cFOUTPUT>
  15.         only has <CFOUTPUT>#Len(form.myText)#</cFOUTPUT>
  16.         characters.  You cannot output the <CFOUTPUT>#form.removeChars#</cFOUTPUT>
  17.         middle characters of this string because it is not long enough
  18.         <CFELSE>
  19.         
  20.         <P>Your original string: <CFOUTPUT>#form.myText#</CFOUTPUT>
  21.         <P>Your changed string, showing only the <CFOUTPUT>#form.removeChars#</CFOUTPUT> middle characters:
  22.         <CFOUTPUT>#Mid("#Form.myText#", "#Form.countChars#", "#form.removeChars#")#</CFOUTPUT>
  23.         </CFIF>
  24.     <CFELSE>
  25.     <P>Please enter a string
  26.     </CFIF>
  27. </CFIF>
  28.  
  29. <FORM ACTION="mid.cfm" METHOD="POST">
  30. <P>Type in some text
  31. <BR><INPUT TYPE="Text" NAME="MyText">
  32. <P>How many characters you want to return?
  33. <SELECT NAME="RemoveChars">
  34.    <OPTION VALUE="1">1
  35.    <OPTION VALUE="3" SELECTED>3
  36.    <OPTION VALUE="5">5
  37.    <OPTION VALUE="7">7
  38.    <OPTION VALUE="9">9</SELECT>
  39.  
  40. <P>At what position do you want to start?
  41. <SELECT NAME="countChars">
  42.    <OPTION VALUE="1">1
  43.    <OPTION VALUE="3" SELECTED>3
  44.    <OPTION VALUE="5">5
  45.    <OPTION VALUE="7">7
  46.    <OPTION VALUE="9">9</SELECT>
  47. <INPUT TYPE="Submit" NAME="Remove characters">
  48. </FORM>
  49.  
  50. </BODY>
  51. </HTML>       
  52.