Great Ideas. Always Flowing.

We are not happy until you are happy. Client satisfaction guaranteed. Whatever your needs and requirements, we have the skills and resources for the job!

Quick login...


Or... now make it easy with Facebook Integration
Connect via Facebook



Top Sellers

Frustrated over the lack of customization for your user's registration fields? Dynamically setup your DNN Portal with custom registration fields, layout, questions, and other core integration options......

Ultra Video Gallery is a brother product of Ultra Media Gallery, UVG allows you to upload videos in various format and automatically encode them to flv or H264 format, you also can add videos from internet or record live videos from your webcam.

Build high performance, completely customizable data-entry forms and views driven by your DNN and external databases. New built-in tools make it a snap to quickly create data entry forms, data views, and even database tables. Plus, add your own HTML, CSS, Javascript, SQL commands, stored procedures,

The most advanced DotNetNuke shopping cart on the planet. Easy to use e-Commerce, Secure Shopping Cart Software and SEO friendly. B2C / B2B Ecommerce Sites.

One stop solution for events calendar and events registration! FREE DOWNLOAD is available now!

Counting words in a text box script
Last Post 02-21-2008 07:25 AM by John Allen. 2 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
Kevin GoncaloUser is Offline
new to the springs
new to the springs
Posts:5
Avatar

--
02-21-2008 06:45 AM

    Can anyone help. I have a client who wants to charge a $1 per word for text entered into a tex box for a classified add page.

    I am assuming this would be a client side script that would count the words and then I can use the total number to populate the total cost.

    Does anyone have a script that I could use to count words in Dynamic Forms?

    ANY HELP is greatly appreciated.

     

    Kevin

    John AllenUser is Offline
    skipping stones
    skipping stones
    Posts:5
    Avatar

    --
    02-21-2008 07:18 AM

    Below is code that Chad first offered that lists Dynamic Forms captured data as a common table. I modified it for my purposes. Notice the use of "CHARINDEX(' ',@Question)." I used it to find and eliminate unwanted characters. You can set up a cursor and loop through looking for the space character assuming that for every space you find you have found a word. Count the spaces and add one at the end for the last word.

    Hope this helps.


    -- sp_DynamicForms_ExportFormResultsInTempTable
    -- to run: sp_DynamicForms_ExportFormResultsInTempTable 466, 'Y'

    --------------------------------------------------------------------------
    -- IF AN OLDER VERSION OF THIS STORED PROCEDURE IS LOADED, THEN UNLOAD IT
    ----------------------------------------------------------------------------
    if exists (select * from sysobjects
    where id = object_id('dbo.sp_DynamicForms_ExportFormResultsInTempTable') and sysstat & 0xf = 4)
     drop PROCEDURE dbo.sp_DynamicForms_ExportFormResultsInTempTable
    GO

    ----------------------------------------------------------------------------
    -- LOAD THIS STORED PROCEDURE
    ----------------------------------------------------------------------------
    Create Procedure sp_DynamicForms_ExportFormResultsInTempTable
        @ModuleID   int    = null,
        @PrintSQLToExecute varchar(1)  = null

    AS

    ----------------------------------------------------------------------------
    -- TURN OFF ROW COUNT DISPLAY & WARNING MESSAGES
    ----------------------------------------------------------------------------
    SET NOCOUNT ON
    SET ANSI_WARNINGS OFF

    ----------------------------------------------------------------------------
    -- DROP TEMPORARY TABLES LEFT OVER FROM PREVIOUS IMTERRUPTED RUNS
    ----------------------------------------------------------------------------
    --if (SELECT object_id('tempdb..tblExportFormResults')) IS NOT NULL
    -- drop table tblExportFormResults
    if exists (select * from sysobjects where id = object_id(N'dbo.tblExportFormResults') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    drop table dbo.tblExportFormResults

    ----------------------------------------------------------------------------
    -- DEFINE TEMPORARY VARIABLES
    ----------------------------------------------------------------------------
    Declare @Question VarChar(500);
    Declare @DynamicQuestionID uniqueidentifier;
    Declare @SQLSelect VarChar(100);
    Declare @SQLToUse VarChar(8000);
    Declare @SQLToUseJoin VarChar(8000);
    Declare @SQLToExecute Varchar(8000);
    Declare @Alias    VarChar(10);
    Declare @intCounter Int;

    set @Question = '';
    set @SQLSelect = '';
    set @SQLToUse = '';
    set @intCounter = 0;
    set @Alias = '';
    set @SQLToUseJoin = '';

    ----------------------------------------------------------------------------
    -- DECLARE AND OPEN CURSOR USED TO BUILD TABLE
    ----------------------------------------------------------------------------
    Declare curBubba Cursor
    FOR
    SELECT Question, DynamicQuestionID
    FROM dnn_DynamicForms_Question
    where QuestionType <> 'HTML'
    AND QuestionType <> 'HR'
    AND InActive=0
    AND ModuleID = @ModuleID
    ORDER BY SortOrder
    FOR READ ONLY;

    OPEN curBubba;
    FETCH NEXT FROM curBubba INTO @Question, @DynamicQuestionID;

    WHILE @@FETCH_STATUS = 0
    BEGIN

     WHILE CHARINDEX('/',@Question) > 0
     BEGIN
      SET @Question =   SUBSTRING(@Question, 1, CHARINDEX('/',@Question)-1)
          + ' '
          + SUBSTRING(@Question, CHARINDEX('/',@Question) + 1, LEN(@Question))
     END

     WHILE CHARINDEX('.',@Question) > 0
     BEGIN
      SET @Question =   SUBSTRING(@Question, 1, CHARINDEX('.',@Question)-1)
          + ' '
          + SUBSTRING(@Question, CHARINDEX('.',@Question) + 1, LEN(@Question))
     END

     WHILE CHARINDEX('(',@Question) > 0
     BEGIN
      SET @Question =   SUBSTRING(@Question, 1, CHARINDEX('(',@Question)-1)
          + ' '
          + SUBSTRING(@Question, CHARINDEX('(',@Question) + 1, LEN(@Question))
     END

     WHILE CHARINDEX(')',@Question) > 0
     BEGIN
      SET @Question =   SUBSTRING(@Question, 1, CHARINDEX(')',@Question)-1)
          + ' '
          + SUBSTRING(@Question, CHARINDEX(')',@Question) + 1, LEN(@Question))
     END

     WHILE CHARINDEX(' ',@Question) > 0
     BEGIN
      SET @Question =   SUBSTRING(@Question, 1, CHARINDEX(' ',@Question)-1)
          + SUBSTRING(@Question, CHARINDEX(' ',@Question) + 1, LEN(@Question))
     END

     SET @Question = Ltrim(Rtrim(@Question))

     set @intCounter = @intCounter + 1;
     set @Alias = '[RJoin_' + CAST(@intCounter as varchar(20)) + ']';

     if DataLength(@SQLToUse) = 0
     BEGIN
      --set @SQLToUse = 'SELECT A.uniqueresponseID, a.UserID, A.UserName, IsNull(' + @Alias + '.response,''N/A'') as [' + @Question + '] '
      set @SQLSelect = 'SELECT '
      set @SQLToUse = 'A.uniqueresponseID, a.UserID, A.UserName, IsNull(' + @Alias + '.response,''N/A'') as [' + @Question + '] '
      set @SQLToUseJoin = '
    From (
      SELECT  distinct Y.uniqueresponseID, Y.UserID, B.UserName
      from [dnn_DynamicForms_QuestionResponse] As Y
      inner join dnn_DynamicForms_Question  as Z on (Y.DynamicQuestionID = Z.DynamicQuestionID)
      Left Outer Join dnn_Users B on B.UserID = Y.UserID
      where Z.ModuleID = ' + Cast(@ModuleID as varchar(20)) + '
    ) As A
    Left Outer join dnn_DynamicForms_QuestionResponse as ' + @Alias + ' on (A.uniqueresponseID = ' + @Alias + '.uniqueresponseID and ''' + Cast(@DynamicQuestionID as varchar(50))+ ''' = ' + @Alias + '.DynamicQuestionID)
    '
     END
     ELSE
     BEGIN
      set @SQLToUse = @SQLToUse + ', ' + @Alias + '.response as [' + @Question + '] '
      set @SQLToUseJoin = @SQLToUseJoin + 'Left Outer join dnn_DynamicForms_QuestionResponse as ' + @Alias + ' on (A.uniqueresponseID = ' + @Alias + '.uniqueresponseID and ''' + Cast(@DynamicQuestionID as varchar(50))+ ''' = ' + @Alias + '.DynamicQuestionID)
    '
     END; 

        FETCH NEXT FROM curBubba INTO @Question, @DynamicQuestionID;
    END

    CLOSE curBubba;
    DEALLOCATE curBubba;

    set @SQLSelect = ltrim(rtrim(@SQLSelect)) + ' '
    set @SQLToExecute = @SQLSelect + @SQLToUse + 'into tblExportFormResults ' + @SQLToUseJoin

    --set @SQLToExecute = @SQLToUse + @SQLToUseJoin
    if @PrintSQLToExecute = 'Y'
     print @SQLToExecute
    else
     EXEC(@SQLToExecute)
     SELECT *
     FROM tblExportFormResults

    -----------------------------------------------------------------
    -- REMOVE TEMPORARY TABLES
    -----------------------------------------------------------------
    --if (SELECT object_id('tempdb..tblExportFormResults')) IS NOT NULL
    -- drop table tblExportFormResults
    --if exists (select * from sysobjects where id = object_id(N'dbo.tblExportFormResults') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    --drop table dbo.tblExportFormResults

    ----------------------------------------------------------------------------
    -- TURN ON ROW COUNT DISPLAY & WARNING MESSAGES
    ----------------------------------------------------------------------------
    SET NOCOUNT OFF
    SET ANSI_WARNINGS ON

    GO

    John AllenUser is Offline
    skipping stones
    skipping stones
    Posts:5
    Avatar

    --
    02-21-2008 07:25 AM

    Oh, and you will want to start by trimming your text string ... something like this: SET @Question = Ltrim(Rtrim( @Question ))

    You are not authorized to post a reply.


     
     

    Join our mailing list...

    Get current news and events the easy way
    Subscribe Me

    Recent Blogs...

     
    Copyright 2005 - 2011 by Data Springs, Inc.
     
  • film izle
  • 720 izle
  • film
  • sinema izle
  • film makinesi
  • T�rk�e dublaj film
  • film izle
  • film izle
  • baglan film izle
  • sinema izle
  • 1080 film izle
  • film mercegi