>- see footer for list info -<
<!--- I keep getting an error which has something to do with the cfif
below... Invalid CFML construct --->
<cfloop query="qGetHeadings">
            <option value="#qGetHeadings.headingID#" <cfif
isDefined('form.headingID'><cfif form.headingID eq
"#headingID#">selected</cfif></cfif>>#qGetHeadings.headingName#</option>
          </cfloop>


Firstly, 
<cfif form.headingID eq "#headingID#">
can be written more succinctly as 
<cfif form.headingID eq headingID>

Secondly, the second headingID variable is unscoped, do you know what headingID 
you're talking about?  I assume you want it to be qGetHeadings.headingID.  If 
so, write it as
<cfif form.headingID eq qGetHeadings.headingID> 
Coldfusion looks through all the scopes trying to work out which scope any 
unscoped variable belongs to.  I can't remember the order it does it in; I'm 
assuming inside a cfquery it checks the query scope first, but I could be 
wrong.  Give your server a break and scope this variable :-)

Thirdly, the thing causing the error is an unclosed bracket:
<cfif isDefined('form.headingID'>
should be
<cfif isDefined('form.headingID')>


--duncan

Fife Council requests that you "Think Green" and only print this email if 
absolutely necessary

>>> "Kylie Lindstrom" <[EMAIL PROTECTED]> 30/10/2008 02:02 >>>
>- see footer for list info -<
Hi All,
 
Attempting to use the Ryan M BeMiller example to chain two selects in a
form and not having much luck...
Here is my code...
 
    <cfoutput>
 
 
<!--- the action goes to a page which just appends the appropriate
fields in the db --->

     <form action="grDocsPagesAdd_Act.cfm" method="post"
enctype="multipart/form-data">
  <input type="hidden" name="subHeading_required" value="Reference
Heading is required!">
  <input type="hidden" name="headingID_required" value="Reference
Category is required!">
      <table width="100%" border="0" cellpadding="4" cellspacing="1"
class="back_drkr">
      <tr>
        <td colspan="2" class="tbl_rowhdrs1">Add a new document</td>
      </tr>
      <tr>
        <td class="tbl_rowhdrs2">Document Heading</td>
        <td class="tbl_main"><input name="docName" type="text"
id="docName" value="">
          
        </td>
      </tr>
 
<!--- querying the headings table which contains headingID, headingName
--->

      <cfquery name="qGetHeadings" datasource="groupRiskDocuments">
          SELECT *
          FROM headings
          ORDER BY headingID
      </cfquery>    
      <tr>
        <td class="tbl_rowhdrs2">Document Topic</td>
        <td class="tbl_main">
 
<!--- dynamically populate the first drop down list based on the
qGetHeadings query --->
<!--- I keep getting an error which has something to do with the cfif
below... Invalid CFML construct --->
          <select name="headingID" required="yes"
onchange="this.form.submit()">
          <option value="">-- Document Topics --</option>
          <cfloop query="qGetHeadings">
            <option value="#qGetHeadings.headingID#" <cfif
isDefined('form.headingID'><cfif form.headingID eq
"#headingID#">selected</cfif></cfif>>#qGetHeadings.headingName#</option>
          </cfloop>
        </select>
 
<!--- store the selected headingID after the select submits itself --->
    <cfif isDefined('form.headingID')>
    <cfset page.headingID = form.headingID>
    </cfif>    
    </td>
  </tr>
 
<!--- if the first selection has been made, display the second drop down
list with appropriate subheadings --->
<cfif isDefined('page.headingID')>
 
<!--- querying the subheadings table which contains subheadingID,
subheadingName, headingID, based on selected headingID from first query
--->
      <cfquery name="qGetSubHeadings" datasource="groupRiskDocuments">
          SELECT *
          FROM subheadings
          WHERE subheadings.headingID = #page.headingID#
          ORDER BY subheadingID
      </cfquery>
  <tr>
    <td class="tbl_rowhdrs2">Document Sub-topic</td>
    <td class="tbl_main">
 
<!--- dynamically populate the second drop down list based on the
qGetSubHeadings query --->
        <select name="subheadingID" required="yes">
          <option value="">-- Document Sub-topics --</option>
          <cfloop query="qGetSubHeadings">
              <option
value="#qGetSubHeadings.headingID#">#qGetSubHeadings.subheadingName#</op
tion>
          </cfloop>
        </select>
       
    </td>
  </tr>
  </cfif>

<!--- these are other fields that need to be updated, not involved with
the chained selects --->  
  <tr>
    <td class="tbl_rowhdrs2">Date <i><span
class="riskdoctext">(dd/mm/yyyy)</span></i></td>
    <td class="tbl_main"><input name="StoryUpdateDate" type="text"
id="StoryUpdateDate" value="<cfoutput>#DefaultDate#</cfoutput>"></td>
  </tr>
 <tr>
    <td colspan="2" class="tbl_rowhdrs2">Story Text</td>
  </tr>
             <tr> 
            <td colspan="2" class="tbl_main">
            <div id="docText">            
            <textarea name="docText" cols="300" rows="30" id="docText"
style="width:500px; height:200px;"></textarea>
            </div></td>
            </tr> 
    <tr>
    <td class="tbl_rowhdrs2">Reference Document</td>
        <td class="tbl_main"><input type="file" name="docFileName"
class="flat">
        </td>
  </tr>
  <tr>
    <td colspan="2" class="tbl_rowhdrs2">
     <input name="Submit" type="submit" class="buttons" value="Add new
doc"> <input name="reset" class="buttons" type="reset" value="Clear
Form" /></td>
  </tr>
</table>
</form>
</cfoutput>
_______________________________________________

For details on ALL mailing lists and for joining or leaving lists, go to 
http://list.cfdeveloper.co.uk/mailman/listinfo 

--
CFDeveloper Sponsors:-
>- cfdeveloper Hosting provided by www.cfmxhosting.co.uk -<
>- Lists hosted by www.Gradwell.com -<
>- CFdeveloper is run by Russ Michaels, feel free to volunteer your help -<

**********************************************************************
This email and any files transmitted with it are confidential and intended 
solely for the use of the individual or entity to whom they are addressed and 
should not be disclosed to any other party. 
If you have received this email in error please notify your system manager and 
the sender of this message.

This email message has been swept for the presence of computer viruses but no 
guarantee is given that this e-mail message and any attachments are free from 
viruses.

Fife Council reserves the right to monitor the content of all incoming and 
outgoing email.

Fife Council
************************************************


_______________________________________________

For details on ALL mailing lists and for joining or leaving lists, go to 
http://list.cfdeveloper.co.uk/mailman/listinfo

--
CFDeveloper Sponsors:-
>- cfdeveloper Hosting provided by www.cfmxhosting.co.uk -<
>- Lists hosted by www.Gradwell.com -<
>- CFdeveloper is run by Russ Michaels, feel free to volunteer your help -<

Reply via email to