Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

an urgent question, thanks!

Posted on 2003-11-10
9
Medium Priority
?
333 Views
Last Modified: 2013-12-24
Hi, everybody:

Now, I am working on a survey using ColdFusion. It's my first time to use ColdFusion to design a real project. I have a question here: the survey is very long and it has about 40 questions. According to the requirement, I have to separete the survey to 4 different pages. That is, on each page, i will use a form. So, if I want to add the input result, how can I design the insert page? I should design a insert page for each of them? Another question is: on the 4 pages, inside the form, how to define the action="?", the action page for these 4 pages are the same?

Thanks a lot!
0
Comment
Question by:xiaobing
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 1

Accepted Solution

by:
kjuliff earned 500 total points
ID: 9715851
You can't have the action the same for the four pages. I'd only code the form proper on the final page. I would have 3 temporary forms for the other pages each going to the next temp form page.

eg
page 1 form1 action  = form2 submit name = "next" pass input filds to form2
page 2 form2 action = form3 submit name = "next" value of form1 fields passed to next page as hidden
page 3 form3 action = final form submit  name = "next"  value of form1 and form2 fields passed to next page as hidden
page 4 final form - actually does the work as has its own input fields and the passed hidden ones from the previous forms
0
 
LVL 25

Assisted Solution

by:James Rodgers
James Rodgers earned 500 total points
ID: 9715875
try something like this

survey section1

<form name="survey1" action="survey2.cfm" method="post">


and in survey2.cfm

<cfquery name="" datasource=""
insert into tblsurvey q1,q2,q3,q4,q5 values(<cfqueryparam value="form.q1">,...)

</cfquery>

and then in the same page
<form name="survey2 action="survey3.cfm">

etc

0
 
LVL 17

Expert Comment

by:anandkp
ID: 9720022
Hi

ur requirement is a special case i wld say :)

what i wld do is - have the same page [instead of 4 pages] do the job for me

<form name="frm" action="onesinglepage.cfm" method="post">
<cfif condition 1>
   show the first form fields
<cfelseif >
show 2nd form details
..


..

</cfif>
<input type="submit">
</form>

On "onesinglepage.cfm" identify which form is being submitted - by using a ID & do the needfull processing with the DB & after that redirect teh user back to the first page with next ID - so as to show the next form ...

HTH .... let me know incase u need more explanation !

K'Rgds
Anand
0
Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

 
LVL 4

Expert Comment

by:procept
ID: 9720699
Hi,

you can make page 2 the action for page 1, make page 3 the action of page 2, etc.

On each page you can store the previous entered values as hidden fields or as session variables. After the last page, do just one insert. Anand is right, it can be done on a single page, but, that makes the code much longer and maybe a little confusing. ;-)

HTH,

Chris

0
 
LVL 17

Expert Comment

by:anandkp
ID: 9720807
confusing ??? why do u think so ???

I guess a carefully planned code - is much shorter, efficient, easy to understand, implement & maintain !
0
 
LVL 2

Expert Comment

by:iamari
ID: 9722370
only problem with the solution above is the *abandoned cart* syndrom. what if user never finishes the whole thing? you don't want to save incomplete results.

passing along field values from one page to another is cumbersome, especially when you want to make changes.

i would create a scrap table, identical to the real one. create a single action template and save bunches of fields to the scrap table until the end. if everything checks out, copy the whole record from the scrap table to the new one

<cftransaction>

<!--- comes from first page, no ID yet --->
<cfif not isDefined('form.myID')>
    <cfquery name="getID" datasource="myDNS">
       if (select max(myID) from myScrapTable) is null
       select myID=1
       else select max(myID)+1 as myID from myScrapTable
   </cfquery>

   <cfquery name="saveBunch" datasource="myDNS">
       insert into myScrapTable (myID, userField1, userField2)
       values (#getID.myID#, '#userField1#', '#userField2#')
   </cfquery>

<!--- comes for a later page, ID should exist --->
<cfelse>
   <cfquery name="saveBunch" datasource="myDNS">
       update myScrapTable set
       userField3 = '#form.userField3#'
       userField4 = '#form.userField4#'
       where myID = #form.myID#
   </cfquery>
</cfif>

</cftransaction>

pass the unique ID back to next user page, like:

<cflocation url="myNextPage?myID=#myID#">

all following pages should include a hidden field for myID
<cfoutput>
<input type="hidden" name="myID" value="#myID#">
</cfoutput>

on the last page, pass a variable, say like: <input type="hidden" name="finish">

on the action page, add another transaction, like:

<!--- last bunch came from last user page, save everything on production table --->
<cfif isDefined('form.finish')>
  <cftransaction>
   <!--- get the whole record from scrap table --->
      <cfquery name = "getScrapRecord" datasource="myDNS">
         select * from myScrapTable where myID=#form.myID#
      </cfquery>
   <!--- get a prodID --->
   <cfquery name="getProdID" datasource="myDNS">
       if (select max(myProdID) from myProdTable) is null
       select myProdID=1
       else select max(myProdID)+1 as myProdID from myProdTable
   </cfquery>
   <cfquery name="mainQry" datasource="myDNS">
       insert into myProdTable (myProdID, userField1, userField2, userField3, userField4)
       values = (#myProdID#, getScrapRecord.userField1, getScrapRecord.userField2,
       getScrapRecord.userField3, getScrapRecord.userField4)
   </cfquery>
  </cftransaction>
</cfif>

after that, eventually run a scheduled template to clean up the scrap table periodically of incomplete records
0
 
LVL 4

Expert Comment

by:procept
ID: 9753564
Hi,

@Anand:

> confusing ??? why do u think so ???

> I guess a carefully planned code - is much shorter, efficient, easy to understand, implement & maintain !

I agree 100%!!!

But... ;-))

Doing all form parts and actions in one single page will make the code per page always longer and less easy to read. For an experienced CF programmer that should not be a problem, but, especially beginners tend to be confused (and frustrated) by long code.


@iamari

> only problem with the solution above is the *abandoned cart* syndrom.
> what if user never finishes the whole thing? you don't want to save incomplete results.

Well, you don't save incomplete results when you pass along field values from one page to another or use cookie.

> passing along field values from one page to another is cumbersome, especially when you want to make changes.

Depends on how you set up your form and how you pass the values. Can be done in a single loop for all fields (like 3 lines of code or so).

A scrap table also is a good solution, but, requires more queries plus a cleanup...

There's always more than one possible solution, in the end it depends on your taste. ;-)

Cheers,

Chris

0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question