I've got a cfform that submits data to a file which runs validation checks,
then submits the data if correct to the database. If any data is missing it
lets the user know what is missing and asks them to go back and fill in that
information (using JavaScript onClick="history.go(-1)"). I've got
preservedata="yes" in the cfform tag and all of the changes/adds are being
preserved except for one cfselect field: Proposed Work. This field is linked
to another field, Project Type, and the Proposed Work list is dynamically
generated dependent upon the selected Project Type. When going back in add
mode the Proposed Work list resets to all possible selections (instead of the
shortened list based on Project Type)and the first option is selected. When
going back in edit mode, the Proposed Work resets to what is in the database.
Not only is this confusing to the user, but it allows for incorrect Proposed
Work / Project Type relationships to be submitted to the database.
I think the reason it doesn't work is the JavaScript I am using to create the
relationship between the two fields, but I'm at a loss as to how to fix it.
I've tried putting all the code into one file and submitting to itself, but
that creates a whole host of other problems. Any ideas?
Here's some of the code:
<!--- Project Type --->
<tr>
<td width="115px" class="sem" style="text-align:left;" >Project Type</td>
<td colspan="3" width="435px" align="left">
<cfif IsDefined("mode") and mode eq "edit" and IsDefined("rtp") and rtp
neq "">
<cfselect name="project_type" id="project_type" query="qdProjType"
value="project_type" display="project_desc" selected="#qdRTP.project_type#"
queryPosition="below" style="width:435px;" onchange="toggleopened_date(
document.form_rtpinfo.project_type.options[
document.form_rtpinfo.project_type.selectedIndex ].value );
FindProposedWork(this.options.selectedIndex); changeProjectType();" >
<option value="" style="width:435px;"> </option>
</cfselect>
<cfelse>
<cfselect name="project_type" size="1" id="project_type"
query="qdProjType" value="project_type" display="project_desc"
<!---selected=""---> queryPosition="below" required="yes" style="width:435px;"
onchange="toggleopened_date( document.form_rtpinfo.project_type.options[
document.form_rtpinfo.project_type.selectedIndex ].value );
FindProposedWork(this.options.selectedIndex);">
<option value="" style="width:435px;"> </option>
</cfselect>
</cfif>
</td>
</tr>
<cfif (IsDefined("mode") and mode eq "edit") or (Not IsDefined("rtp"))>
<script>
<!--
var NumberOfProjectTypes =
document.form_rtpinfo.project_type.options.length;
var ProposedWorkProjectTypeArray = new Array(NumberOfProjectTypes);
ProposedWorkProjectTypeArray[0] = new Array();
ProposedWorkProjectTypeArray[0][0] = new Option("Select Proposed
Work...","");
<cfloop index="i" from="1" to="#qdProjType.recordcount#">
ProposedWorkProjectTypeArray[<cfoutput>#i#</cfoutput>] = new
Array();
<cfquery name="selectedWork_project_type" dbtype="query">
select proposed_work from qdRtpWorkEdit where project_type
= #qdProjType.project_type[i]# order by proposed_work
</cfquery>
<cfoutput query="selectedWork_project_type">
ProposedWorkProjectTypeArray[#i#][#selectedWork_project_type.CurrentRow#]=new
Option('#JSStringFormat(selectedWork_project_type.proposed_work)#','#JSStringFormat(selectedWork_project_type.proposed_work)#')
</cfoutput>
</cfloop>
//-->
</script>
</cfif>
<!--- Proposed Work... --->
<tr>
<td width="115px" class="sem" style="vertical-align:top; padding-top:4px;
text-align:left">Proposed Work</td>
<td colspan="3" width="435px" align="left">
<cfif IsDefined("mode") and mode eq "edit" and IsDefined("rtp") and
rtp neq "">
<cfselect name="proposed_work" id="proposed_work"
query="qdProposedWork" value="proposed_work" display="proposed_work"
selected="#qdRTP.proposed_work#" onchange="toggleOther2(
document.form_rtpinfo.proposed_work.options[
document.form_rtpinfo.proposed_work.selectedIndex ].value );
changeProposedWork();" style="width:435px;" queryPosition="below" >
<option value="oth2" class="other_italic">--other--</option>
</cfselect>
<input type="text" name="other2" style="width:429px;
visibility:hidden" />
<cfelse>
<cfselect name="proposed_work" id="proposed_work"
query="qdRtpWork" value="proposed_work" display="proposed_work"
onchange="toggleOther2( document.form_rtpinfo.proposed_work.options[
document.form_rtpinfo.proposed_work.selectedIndex ].value );"
style="width:435px;" queryPosition="below">
<option value="oth2" class="other_italic" >--other--</option>
</cfselect>
<input type="text" name="other2" style="width:429px;
visibility:hidden" />
</cfif>
</td>
</tr>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f
Archive:
http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:4200
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15