Scot VanAlstine wrote:

>I have a window where a user can pick a topic and click an edit button.
>If the window is empty and does not contain something to select they can still 
>click on the "Edit Spec" button and it gets an error.  How would I disable the 
>"Edit Spec" button if there is nothing to select?
>
>  
>
Scot,

Everyone's answers so far are correct. However, I would suggest you go a 
stage further than only removing the submit button.  It is possible to 
submit a form by pressing the return key whether there is a submit 
button or not.  To prevent anyone submitting the empty form, I would 
recommend that you remove the complete form from the display of the page.

<cfif pagetopic.recordcount gt 0>
    <!--- Display the form here --->
<cfelse>
    <!--- Only display an error message here --->
</cfif>

A few comments about your code :

><body>
><CFQUERY NAME="pagetopic" DATASOURCE="#application.webtools#">
>   SELECT class_id, title FROM org_class
>   WHERE org_id = '#cookie.organization#'
>   AND class_type > 1
>   ORDER BY title
></CFQUERY>
>  
>
Try to keep queries and any other processing code out of the main 
display of the page.  Put them in seperate files, so that you can reuse 
them by cfincluding them, or put them above the <html> tag wrapped in a 
<cfsilent> tag

><FORM method="post" action="specchoice.cfm" name="">
>  <TABLE border="0">
>    <TR>
>      <TD>
>          <CFSET #pagetopic_count# = 0>
>  
>
Hashes (pound signs) are not required in this use of cfset :    <cfset 
pagetopic_count = 0> will suffice.

>        <SELECT name="class_id" size="5">
>          <CFOUTPUT query="pagetopic">
>            <CFIF #pagetopic_count# is 0>
>              <OPTION value="#class_id#" SELECTed>#title#
>              <CFSET #pagetopic_count# = 1>
>              <cfelse>
>              <OPTION value="#class_id#">#title#
>            </CFIF>
>  
>
This will only ever make the first item in your dropdown box be 
selected.  You can do this slightly more neatly like this :

<cfoutput query="pagetopic">
    <option value="#class_id#" <cfif pagetopic.currentrow eq 
1>selected</cfif>>#title#</option>
</cfoutout>

Another option is to use an inline if - not the most popular function in 
CF and supposedly slower than an ordinary CFIF, but doesn't make any 
difference with CFMX+ because the code is compiled and not interpreted. 
This is actually my prefered method, because, personally, I think it 
makes cleaner code and the colour coding in DWMX handles it better than 
a CFIF in the middle of an html tag. ;oD

<option value="#class_id#" #IIF(pagetopic.currentrow eq 
1,de('selected'),de(''))#>

Hope this all helps.

Regards

Stephen


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:15:760
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/15
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:15
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to