ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Dell PowerEdge Servers
  #1  
Old February 9th, 2004, 02:34 AM
ausboy214 ausboy214 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 2 ausboy214 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
3 way form

I am attempting to create a user survey and depending on whish radio button the user selects I want to take them to a different page. (minimal=thankyou.htm, medium=part2.cfm, high=part3.cfm).
Obviously I also need to pass a unique identifier (ie the SOEID) so that I can update the particular record with the responses from the proceeding pages.
I am no Cold Fusion guru, and am simply trying to modify the code UltraDev has given me.
Any assistance would be greatly appreciated.

part1.cfm
----------------------------------------------------

<cfinclude template="../../Connections/data_access.cfm">
<cfscript>
// *** Edit Operations: declare variables

// set the form action variable
MM_editAction = CGI.SCRIPT_NAME;
If (CGI.QUERY_STRING NEQ "") {
MM_editAction = MM_editAction & "?" & CGI.QUERY_STRING;
}

// boolean to abort record edit
MM_abortEdit = false;

// query string to execute
MM_editQuery = "";
</cfscript>
<cfscript>
// *** Insert Record: set variables

If (IsDefined("MM_insert")) {

MM_editDatasource = #MM_data_access_DSN#;
MM_editUserName = #MM_data_access_USERNAME#;
MM_editPassword = #MM_data_access_PASSWORD#;
MM_editTable = "main";
MM_editRedirectUrl = "part2.cfm";
MM_editRedirectUrl1 = "part3.cfm";
MM_fieldsStr = "a1_1_soeid|value|a1_2_bus_name|value|a1_4_locn_id|value|a1_5_situation|value";
MM_columnsStr = "a1_1_soeid|',none,''|a1_2_bus_name|',none,''|a1_4_locn_id|none,none,NULL|a1_5_situation|none,none,NU LL";

// create the MM_fields and MM_columns arrays
MM_fields = ListToArray(MM_fieldsStr,"|");
MM_columns = ListToArray(MM_columnsStr,"|");

// set the form values
For (i=1; i+1 LE ArrayLen(MM_fields); i=i+2) {
MM_fields[i+1] = IIf(IsDefined(MM_fields[i]),"FORM." & MM_fields[i],DE(""));
}

// append the query string to the redirect URL
If (MM_editRedirectUrl NEQ "" AND CGI.QUERY_STRING NEQ "") {
If (Find("?", MM_editRedirectUrl) EQ 0) {
MM_editRedirectUrl = MM_editRedirectUrl & "?" & CGI.QUERY_STRING;
} Else {
MM_editRedirectUrl = MM_editRedirectUrl & "&" & CGI.QUERY_STRING;
}
}
}
</cfscript>
<cfscript>
// *** Insert Record: construct a sql insert statement

If (IsDefined("MM_insert")) {

// create the insert sql statement
MM_tableValues="";
MM_dbValues="";
For (i=1; i+1 LE ArrayLen(MM_fields); i=i+2) {
FormVal = MM_fields[i+1];
MM_typesArray = ListToArray(MM_columns[i+1],",");
Delim = IIf(MM_typesArray[1] NEQ "none","MM_typesArray[1]",DE(""));
AltVal = IIf(MM_typesArray[2] NEQ "none","MM_typesArray[2]",DE(""));
EmptyVal = IIf(MM_typesArray[3] NEQ "none","MM_typesArray[3]",DE(""));
If (FormVal EQ "") {
FormVal = EmptyVal;
} Else {
If (AltVal NEQ "") {
FormVal = AltVal;
} Else If (Delim EQ "'") { // escape quotes
FormVal = "'" & Replace(FormVal,"'","''","ALL") & "'";
} Else {
FormVal = Delim & FormVal & Delim;
}
}
If (i GT 1) {
MM_tableValues = MM_tableValues & ",";
MM_dbValues = MM_dbValues & ",";
}
MM_tableValues = MM_tableValues & MM_columns[i];
MM_dbValues = MM_dbValues & FormVal;
}
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")";
}
</cfscript>
<cfif Not #MM_abortEdit# AND IsDefined("MM_insert")>
<cfquery name="MM_editCmd" datasource=#MM_editDatasource# username=#MM_editUserName# password=#MM_editPassword#>
#PreserveSingleQuotes(MM_editQuery)#
</cfquery>
<cfif isdefined('Form.a1_1_soeid')>
<cfset client.soe = form.a1_1_soeid>
</cfif>
<cfif #MM_editRedirectUrl# NEQ "" AND #client.sit# EQ "a">
<cflocation url="#MM_editRedirectUrl#" addtoken="no">
<cfelse>
<cflocation url="#MM_editRedirectUrl1#" addtoken="no">
</cfif>
</cfif>
<cfquery name="main" datasource=#MM_data_access_DSN# username=#MM_data_access_USERNAME# password=#MM_data_access_PASSWORD#>
SELECT * FROM main
</cfquery>
<cfquery name="business" datasource=#MM_data_access_DSN# username=#MM_data_access_USERNAME# password=#MM_data_access_PASSWORD#>
SELECT * FROM business
</cfquery>
<cfquery name="locn" datasource=#MM_data_access_DSN# username=#MM_data_access_USERNAME# password=#MM_data_access_PASSWORD#>
SELECT * FROM location
</cfquery>
<html>
<head>
<title>Access to Spatial Data</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
<!--
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div id="banner">Access to Spatial Data - User Needs Analysis</div>
<div id="title">Part 1</div>
<div id="content">
<form method="post" action="<cfoutput>#MM_editAction#</cfoutput>" name="form1">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">A1_1_soeid:</td>
<td>
<input type="text" name="a1_1_soeid" size="20" maxlength="4">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">A1_2_bus_name:</td>
<td>
<select name="a1_2_bus_name">
<cfloop query="business">
<option value="<cfoutput>#business.bus_id#</cfoutput>"><cfoutput>#business.department# | #business.bus_name#</cfoutput></option>
</cfloop>
</select>
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">A1_4_locn_id:</td>
<td>
<select name="a1_4_locn_id">
<cfloop query="locn">
<option value="<cfoutput>#locn.locn_id#</cfoutput>"><cfoutput>#locn.locndesc#</cfoutput></option>
</cfloop>
</select>
</td>
</tr>
<tr>
<td nowrap align="right" valign="top">A1_5_situation:</td>
<td valign="baseline">
<table align="left">
<tr>
<td>
<input type="radio" value="1" name="a1_5_situation" <cfset sit = "a">>
Minimal
<td>
</tr>
<tr>
<td>
<input type="radio" value="2" name="a1_5_situation">
Medium
<td>
</tr>
<tr>
<td>
<input type="radio" value="3" name="a1_5_situation">
High
<td>
</tr>
</table>
<p>
<input type="submit" value="Minimal" onClick="MM_goToURL('parent','part2.cfm');return document.MM_returnValue">
</p>
<p>
<input type="submit" value="Medium" onClick="MM_goToURL('parent','part3.cfm');return document.MM_returnValue">
</p>
<td nowrap align="right">&nbsp;</td>
<td>
<input type="submit" value="Insert Record">
</td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="true">
</form>
</div>
<div id="footer">footer</div>
</body>
</html>

Reply With Quote
  #2  
Old February 9th, 2004, 08:27 AM
kiteless kiteless is offline
Moderator
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,480 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 17 h 33 m 17 sec
Reputation Power: 42
My goodness, that code is pretty horrendous...did Ultradev generate that?

Anyway, one way to handle it is to make the value for each radio button correspond to the page you want to run (part1, part2, part3). Then on the target page, do a cflocation based on the value of that form field. Something like:

<cflocation url="http://mysite.com/#form.a1_5_situation#.cfm" />

so if the user had picke option 2, the cflocation URL would become something like

http://mysite.com/part2.cfm

Reply With Quote
  #3  
Old February 9th, 2004, 06:39 PM
ausboy214 ausboy214 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 2 ausboy214 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanks, but...

kiteless,
thanks for your response. It sent me on the correct direction. The page now takes the user to the correct page depending on what radio button is selected.
The next issue is, how do I pass the soe_id, preferably through the URL, to the next page and then use it to requery the main table so that I only update the correct record?
I have only just started using cold fusion, so please forgive my ignorance!
Thanks in advance.

Reply With Quote
  #4  
Old February 9th, 2004, 08:39 PM
kiteless kiteless is offline
Moderator
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,480 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 17 h 33 m 17 sec
Reputation Power: 42
If the form has a field for soe_id then you don't have to pass it, it is already passed in the FORM scope when the form is submitted.

Not sure what your app is meant to do, but before you go much further I would grab a copy of Ben Forta's CF book and read it. There are probably easier ways to do what you are trying to do but until you have a firmer grasp of CF they won't make much sense.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > 3 way form


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway