I am trying to design the dynamic survey. But when i insert question options 
(label) I get weird behevior. It insert a duplicate but it should not 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Add/Remove Options</title>

<cfquery name="getOptions" datasource="cfelsunrise" dbtype="odbc" >
        select * from questionOptions where questionid=#questionID# and 
surveyID=#surveyID# 
</cfquery>
</head>
<cfif isDefined("btnOption") and isDefined("form.opt") and form.opt neq ''>
        <cfloop index="i"  from="1" to="#ListLen(form.opt)#">
 
                <cfset variables.this=ListGetAt(form.opt,i)>
                <cfquery name="getOptions" datasource="cfelsunrise" 
dbtype="odbc">
                        Select * from questionOptions where 
questionID=#questionID# and surveyID=#surveyID# and options='#variables.this#'
                </cfquery>
                <cfif getOptions.recordcount eq 0>
                        <cfquery name="qryOptionSave" datasource="cfelsunrise" 
dbtype="odbc">
                                SET NOCOUNT ON
                                        insert into questionOptions 
values('#variables.this#',#questionID#,#surveyID#)
                                SET NOCOUNT OFF
                        </cfquery>
                <cfelse>
                        <cfquery name="qryOptionSave2" datasource="cfelsunrise" 
dbtype="odbc">
                                update questionOptions set 
options='#variables.this#' where questionID=#questionID# and 
surveyID=#surveyID# 
                        </cfquery>
                </cfif>
        </cfloop>
        <cflocation 
url="addremoveQuestion.cfm?surveyID=#surveyID#&optionID=#optionID#" 
addtoken="no">
</cfif>


<body>
<form action="" method="post" id="menu" name="menu" >
<cfoutput><input type="hidden" name="questionID" id="questionID" 
value="#questionID#" />
<input type="hidden" name="surveyID" id="surveyID" value="#surveyID#" 
/></cfoutput>


<h1 align="center">Add/Remove Options</h1>

<cfoutput>

<cfloop query="getOptions">
        Option &nbsp;#getOptions.currentrow#:&nbsp;<input type="text" 
name="opt" id="opt" size="40" value="#getOptions.options#"/><br>
</cfloop>
</cfoutput>

<br />
<br />
<input type="hidden" name="optionID" value="#getOptions.id#" />
<input type="hidden" name="surveyID" id="surveyID" value="#surveyID#" />
<input type="submit" name="btnOption" id="btnOption" value="Save Options" />
<!---<input type="submit" name="btnAdd" id="btnAdd" value="Add Option"  />--->
</form>
</body>
</html>


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:304170
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to