• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 283
  • Last Modified:

Coldfusion questions - criteria for the url.

Please review my complete querry...

Based on my querry could you please help identify the criteria i should add to my url to go directly to my topic number 2 without selection topic.

This is my url for example: http://www.zbc.ca/members/org/forum/candidate_e.cfm

Whenever change i select i only see that url:



I will attach the code in my next comments.
0
LelloLello
Asked:
LelloLello
  • 3
  • 2
1 Solution
 
LelloLelloAuthor Commented:
<table border="1" cellpadding="0" cellspacing="0" class="stats">
        	<tr>
            	<td class="hed"><strong>View discussion by:</strong> </td>
				<td>
		           <select name="sortOptions" class="txt" onChange="fnChangeCandidate(0)"> 
						<option value="">Select an option</option>
                        <cfoutput>
				   		<cfloop query="listOptions">
							<option value="#id#" <cfif #isDefined('form.sortOptions')# AND #form.sortOptions# eq #id#>selected</cfif>>#options#</option>
						</cfloop>
                        </cfoutput>
            		</select>    
                    <cfif #isDefined('form.sortOptions')#>
						<cfif #form.sortOptions# EQ 2>
	    	                &nbsp;<input type="button" name="btnAddTopic" value="Propose a New Topic" onClick="location.href='potential_topics.cfm'">                                        	
                        </cfif>
                    </cfif>
                </td>	            
            </tr>
            <!---CHECK TO SEE IF THE USER DECIDED TO SORT BY CANDIDATES--->
            <cfif #isDefined('form.sortOptions')#>
				<cfif #form.sortOptions# EQ 1>
			        <input type="hidden" name="lastSortOption" id="lastSortOption" value="1"/>
                    <cfset tableHeading = ArrayNew(1)>
                    <cfset ArrayAppend(tableHeading, "Topic")>
                    <cfset ArrayAppend(tableHeading, "Response")>
                    <cfset ArrayAppend(tableHeading, "Date of Response")>
                    <cfset ArrayAppend(tableHeading, "Options")>     
					<!---SELECT A CANDIDATE--->
                    <tr>
                        <td class="hed"><strong>Select a candidate:</strong></td>
<td> <select name="candidates" class="txt" onChange="fnChangeCandidate(0)"> 
                                <option value="">Select a candidate</option>
                                <cfoutput>
                                <cfloop query="listCandidates">
                                    <option value="#candidate_id#" <cfif #isDefined('form.candidates')# AND #form.candidates# eq #candidate_id#>selected</cfif>>#first_name# #last_name# - #job_position#</option>
                                </cfloop>                               
                                </cfoutput>
                                </select>
                        </td>
                    </tr>                    
				   </table>          <br/>
                           
                <cfif isDefined("form.xaction") and #form.xaction# eq "true">
                  
                            <table border="1" cellpadding="0" cellspacing="0" class="stats">
                            <cfoutput>
                                <tr>
                                    <th class="hed">#tableHeading[1]#</th>
                                    <th class="hed">#tableHeading[2]#</th>
                                    <th class="hed">#tableHeading[3]#</th>
                                    <th class="hed">#tableHeading[4]#</th>                                    
                                </tr>
                            </cfoutput>
                                <cfloop query="listRelationships">
                                    <cfquery name="listTopics" datasource="Actuaries" username="#application.username#" password="#application.password#">
                                        SELECT id, topic_eng, topic_fr
	                                        FROM discForum_topics
                                        WHERE id = '#listRelationships.topic_id#'
                                        AND active = '1'
                                    </cfquery>
                                    
                                    <cfquery name="listResponses" datasource="Actuaries" username="#application.username#" password="#application.password#">
                                        SELECT id, response, candidate_id, topic_id, responseDate
                                        FROM discForum_responses
                                        WHERE id = '#listRelationships.response_id#'
                                        ORDER BY responseDate ASC
                                    </cfquery>
        
        							<cfquery name="listComments" datasource="Actuaries" username="#application.username#" password="#application.password#">
                                    	SELECT id, comment, member_id, response_id, commentDate
                                        FROM discForum_comments
                                        WHERE response_id = '#listRelationships.response_id#'
                                    </cfquery>
                                <tr>
                                	
                                    <td width="50%">
                                    	<cfif lastTopic NEQ #listTopics.id#>
	                                        <cfoutput>#listTopics.topic_eng#   
                                       	  <input type="hidden" name="topic_id" value="#listTopics.id#"/></cfoutput>
                                        <cfelse>
                                        	&nbsp;
                                        </cfif>
                                    </td>
                                    <td width="50%">
                                        <cfoutput>#listResponses.response#   <br/>
                                        <cfif #listComments.recordcount# gt 0>
                                        	<div style="text-align:right;"><a href="viewComments.cfm?candidate_id=#form.candidates#&topic_id=#listRelationships.topic_id#&response_id=#listResponses.id#" target="_blank">View Member Comments</a></div>
                                        </cfif>
                                        </cfoutput>
                                    </td>
                                    <td width="50%" style="text-align:center;">
                                        <cfoutput>#DateFormat(listResponses.responseDate, "d-mmm-yyyy")# </cfoutput>
                                        
                                        
                                    </td>
                                    <td width="50%">
                                    <cfoutput>
                                    	<cfif #isDefined('form.action')# AND #form.action# eq "showCommentInput">
                                        	<cfif form.response_id eq listRelationships.response_id>
                                                    <textarea name="commentOnResponse" cols="40" rows="5" onKeyPress="return imposeMaxLength(this, 255);"></textarea> <br/>
                                                    <input type="button" name="btnAddComment" value="Add" onClick="fnChangeCandidate(0)">
                                                    <input type="button" name="btnCancel" value="Cancel" onClick="location.href='candidate_e.cfm?action=false&&sortBy=#form.sortOptions#&xaction=true&response_id=#listRelationships.response_id#&topic_id=#listRelationships.topic_id#&candidate_id=#form.candidates#'" />   
                                            </cfif>                                    
                                        <cfelse>
                                        	<cfif listRelationships.candidate_id EQ client.id_number>
                                            	<input type="hidden" name="candidates_response" value="#listResponses.id#"/>

                                                <input type="hidden" name="xaction" value="false" />                                                
                                            	<input id="editResponse" type="button" name="editResponse" value="Edit Response" onClick="location.href='responseToTopic.cfm?newResponse=false&response_id=#listRelationships.response_id#&topic_id=#listRelationships.topic_id#'" />
                                            <cfelse>
												<!---<input id="addComment" type="button" name="addComment" value="Add a Comment" onClick="location.href='candidate_e.cfm?action=showCommentInput&xaction=true&sortBy=#form.sortOptions#&response_id=#listRelationships.response_id#&topic_id=#listRelationships.topic_id#&candidate_id=#form.candidates#'"/> 	                                    --->
                                                <input type="button" id="addComment" name="addComment" value="Add a Comment" onClick="window.open('addComment.cfm?response_id=#listRelationships.response_id#&topic_id=#listRelationships.topic_id#','child','status=0, toolbar=0, location=0, menubar=0','');" />        	
                                                
                                            </cfif>
                                        
                                        </cfif>
                                    </td>
                                    </cfoutput>
                                </tr>
                                <cfset lastTopic = #listRelationships.topic_id#>   
							</cfloop>           
                            </table>

                </cfif>
            <!---IF THE USER SELECTS SORT BY TOPIC--->        
			<cfelseif #form.sortOptions# EQ 2>
			        <input type="hidden" name="lastSortOption" id="lastSortOption" value="2"/>
                    <cfset tableHeading = ArrayNew(1)>
                    <cfset ArrayAppend(tableHeading, "Candidate")>
                    <cfset ArrayAppend(tableHeading, "Response")>
                    <cfset ArrayAppend(tableHeading, "Date of Response")>                    
                    <cfset ArrayAppend(tableHeading, "Options")>    
					<!---for query below - client.id_number NEQ "965001"--->
                    <cfquery name="listTopics" datasource="Actuaries" username="#application.username#" password="#application.password#">
                        SELECT id, topic_eng, topic_fr
                            FROM discForum_topics
			                <cfif client.id_number NEQ "971822">					                            
    	                        WHERE active = 1
                            </cfif>
                    </cfquery>                    
                    
                    <cfif isDefined('form.topic_id') AND form.topic_id NEQ "">
                        <cfquery name="topicActive" datasource="Actuaries" username="#application.username#" password="#application.password#">
                            SELECT id, active, topic_eng
                            FROM discForum_topics                               
                            WHERE id = '#form.topic_id#'
                        </cfquery>                    
                    </cfif>
                        <td class="hed" colspan="2"><strong>Select a Topic (Full text of topic will be displayed once selected.):</strong></td>
                    </tr>
					<tr>
                        <td colspan="2"><select name="topic_id" class="txt" onChange="fnChangeCandidate(0)" style="width: 928px;">
                                <option value="">---Select a Topic---</option>
                                <cfoutput>
                                <cfloop query="listTopics">
                                    <option style="width: 928px;" title="#stripHTML(topic_eng)#" value="#id#" <cfif #isDefined('form.topic_id')# AND #form.topic_id# eq #id#>selected</cfif>>#topic_eng#</option>
                                </cfloop>
                                </cfoutput>
                               </select>
                               &nbsp;&nbsp;
                               <cfif isDefined('form.topic_id') AND form.topic_id NEQ "">
								   <cfif #topicActive.active# eq 0>
                                        <input type="hidden" name="activateTopic" value="" />
                                        <input type="button" name="btnMakeActive" value="Activate Topic" onClick="fnChangeCandidate(4)">                               
                                   </cfif>
                               </cfif>
                        </td>
                    </tr> 
      
                	<cfif isDefined('topicActive.active') AND topicActive.active eq 1>
						<tr>
							<td class="hed" colspan="2">
								Selected Topic:
							</td>
						</tr>
						<tr>
							<td colspan="2">
									<cfoutput>#topicActive.topic_eng#</cfoutput>
							</td>
						</tr>
                        <cfif #isDefined('form.topic_id')# AND #form.topic_id# NEQ "">                 
                        <tr>
                            <td class="hed"><strong>Filter by Candidate:</strong></td>
                            <td> <select name="candidates" class="txt" onChange="fnChangeCandidate(0)">
                                    <option value="">---Show all Candidates---</option>
                                    <cfoutput>
                                    <cfloop query="listCandidates">
                                        <option value="#candidate_id#" <cfif #isDefined('form.candidates')# AND #form.candidates# eq #candidate_id#>selected</cfif>>#first_name# #last_name# - #job_position#</option>
                                    </cfloop>
                                    </cfoutput>
                                    </select>&nbsp; &nbsp;  
									   <cfif checkCandidate.recordcount gt 0>	
	                                        <input type="button" name="btnAddResponse" value="Add New Response" onClick="fnChangeCandidate(3)">                                    
                                       </cfif>
                        	</td>
                        </tr>  
                        <cfelse>
                            <cfset form.candidates = "">
                        </cfif>              
                   </cfif>
				</table>                 <br/>           
                <cfif isDefined("form.xaction") and #form.xaction# eq "true">
                	<cfif #isDefined('form.topic_id')# AND form.topic_id NEQ "">
                            <table border="1" cellpadding="0" cellspacing="0" class="stats">
                            <cfoutput>
                                <tr>
                                    <th class="hed">#tableHeading[1]#</th>
                                    <th class="hed">#tableHeading[2]#</th>
                                    <th class="hed">#tableHeading[3]#</th>
                                    <th class="hed">#tableHeading[4]#</th>                                    
                                </tr>
                            </cfoutput>
                                <cfloop query="listRelationships">
                                    <cfquery name="getCandidates" datasource="Actuaries" username="#application.username#" password="#application.password#">
                                    	SELECT candidate_id, job_position, first_name, last_name
                                        FROM discForum_candidates
                                        <cfif #isDefined('form.candidates')# AND form.candidates NEQ "">
	                                        WHERE candidate_id = '#form.candidates#'   
                                        <cfelse>
                                        	WHERE candidate_id = '#listRelationships.candidate_id#'                                 
                                        </cfif>
                                    </cfquery> 
                                    
                                    <cfquery name="getResponses" datasource="Actuaries" username="#application.username#" password="#application.password#">
                                    	SELECT id, response, responseDate
                                        FROM discForum_responses
                                        WHERE id = '#response_id#'
                                    </cfquery>

        							<cfquery name="getComments" datasource="Actuaries" username="#application.username#" password="#application.password#">
                                    	SELECT id, comment, member_id, response_id
                                        FROM discForum_comments
                                        WHERE response_id = '#response_id#'
                                    </cfquery>
                                <tr>
                                	
                                    <td width="20%">
                                    	<cfif lastCandidate NEQ #listRelationships.candidate_id#>
	                                        <cfoutput>#getCandidates.first_Name# #getCandidates.last_Name#</cfoutput>   
                                        <cfelse>
                                        	&nbsp;
                                        </cfif>
                                    </td>
                                    <td width="65%">
                                        <cfoutput>#getResponses.response#   <br/>
                                        <cfif #getComments.recordcount# gt 0>
                                        	<div style="text-align:right;"><a href="viewComments.cfm?sortOption=2&candidate_id=#getCandidates.candidate_id#&topic_id=#listRelationships.topic_id#&response_id=#getResponses.id#" target="_blank">View Member Comments</a></div>
                                        </cfif>
                                        </cfoutput>
                                    </td>
                                    <td width="10%" style="text-align:center;">
                                        <cfoutput>#DateFormat(getResponses.responseDate, "d-mmm-yyyy")#</cfoutput>
                                    </td>
                                    <td width="25%">
                                    <cfoutput>
                                    	<cfif #isDefined('form.action')# AND #form.action# eq "showCommentInput">
                                        	<cfif form.response_id eq getResponses.id>
                                              
                                                    <textarea name="commentOnResponse" cols="40" rows="5" onKeyPress="return imposeMaxLength(this, 255);"></textarea> <br/>
                                                    <input type="button" name="btnAddComment" value="Add" onClick="fnChangeCandidate(0)">
                                                    <input type="button" name="btnCancel" value="Cancel" onClick="location.href='candidate_e.cfm?action=false&xaction=true&sortBy=#form.sortOptions#&response_id=#listRelationships.response_id#&topic_id=#listRelationships.topic_id#&candidate_id=#getCandidates.candidate_id#'" /> 
                                            </cfif>                                    
                                        <cfelse>
                                        	<cfif listRelationships.candidate_id NEQ client.id_number>
                                        	<input id="addComment" type="button" name="addComment" value="Add a Comment" onClick="window.open('addComment.cfm?response_id=#listRelationships.response_id#&topic_id=#listRelationships.topic_id#','child','status=0, toolbar=0, location=0, menubar=0','');" />                                            <cfelse>
                                            	<input type="hidden" name="candidates_response" value="#getResponses.id#"/>

                                                <input type="hidden" name="xaction" value="false" />                                                
                                            	<input id="editResponse" type="button" name="editResponse" value="Edit Response" onClick="location.href='responseToTopic.cfm?newResponse=false&response_id=#listRelationships.response_id#&topic_id=#listRelationships.topic_id#'" />

											</cfif>
                                        	
                                        </cfif>
                                    </td>
                                    </cfoutput>
                                    
                                </tr>
                                <cfset lastCandidate = #getCandidates.candidate_id#>   
							</cfloop>           
                            </table>
            	
            		</cfif>
	            </cfif>
       </cfif>
	</cfif>
  </table>
        <!---<h4>Results of the 2011 Elections</h4>--->

<!---   END: Content Area --->
        
      </div>
    </td>
	<td width="20"><img src="../../images/wrapper/options-spacer2.gif" alt="" width="20" height="33" border="0"></td>
	<td width="17"><img src="../../images/spacer.gif" alt="" width="17" height="1" border="0"></td>
</tr>
</table>

Open in new window

0
 
LelloLelloAuthor Commented:
.cfm?sortOption=2&candidate_id=969398&topic_id=16&response_id=106

how i'm able to implement this in my code ?
0
 
TechHelpr08210Commented:
Where is the javascript function attached to the select box?

This could be why it is not working.

Please post that code.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LelloLelloAuthor Commented:
<script>

          function fnChangeCandidate(num){
                    if (num == 0){
               document.frmCandidate.method = "post"
                     document.getElementById('xaction').value = "true"
               document.frmCandidate.action = "candidate_e.cfm"
               document.frmCandidate.submit()
                    }
                    else if(num == 1){
                           document.frmCandidate.method = "post"
                           document.getElementById('xaction').value = "true"
                           document.frmCandidate.submit()
                    }
                    else if(num == 2){
                              document.frmCandidate.method = "post";
                              document.getElementById('xaction').value = "true"
                              document.frmCandidate.action = "responseToTopic.cfm";
                              document.frmCandidate.submit();
                    }
                    else if(num == 3){
                              document.frmCandidate.method = "post";
                              document.getElementById('xaction').value = "false"
                              document.frmCandidate.action = "responseToTopic.cfm";
                              document.frmCandidate.submit();
                    }
                    else if(num == 4){
                        document.frmCandidate.method = "post";
                        document.getElementById('xaction').value = "true"
                        document.getElementById('activateTopic').value = "true"                        
                        document.frmCandidate.action = "candidate_e.cfm";
                        document.frmCandidate.submit();                               
                    }
                  
                    
          }
             
            function imposeMaxLength(Object, MaxLen)
            {
              return (Object.value.length <= MaxLen);
            }

    function openChild()
    {
        window.open('addComment.cfm','child','status=0, toolbar=0, location=0, menubar=0','');
    }

</script>
0
 
TechHelpr08210Commented:
You page is not setup to respond to url variables because all of the references are looking only in the form scope. To make your url reference work, you will need to convert url variables into the form scope automatically.

Also, this will only work if the form scope is empty (ie: if there isn't any form information being submitted.

Try putting this code at the top of your page. Let me know how you made out.

 
<cfif structisempty(form)  > <cfset form = url /> </cfif>

Open in new window


Good Luck!
0
 
_agx_Commented:
you will need to convert url variables into the form scope automatically

<cfset form = url />


What's interesting about that code is it doesn't actually overwrite the FORM scope. It creates a local variable referencing URL scope ie #variables.FORM#. The system FORM scope is left intact. To avoid subtle bugs, it's safer to copy the values from one scope to the other imo. Especially as structures are already passed by reference.

<!--- warning, this will overwrite any values in the FORM scope with the same name --->
<cfloop collection="#URL#" item="key">
        <cfset FORM[key] = URL[key]>
</cfloop>

'
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now