Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

<cfselect> problem

Status
Not open for further replies.

grx21

Programmer
Joined
Aug 3, 2001
Messages
45
Location
US
I have a form that dynamically populates a select box. I am trying to have the form do the following:

If the user clicks on first select option "Please select the course you would like to view." (which is not dynamic) and hits the submit button nothing should happen and he/she needs stays on the same form page.

However, if the user clicks on the second option (or third or fourth, and so on) which is dynamically populated he/she will be able to view the course description for the particular course that he/she has selected.

Any help will be greatly appreciated. I have ran out of ideas and advil. :(

<CFQUERY NAME=&quot;GetClass&quot; DATASOURCE=&quot;course-sql&quot;>
SELECT COURSE, COURSE_TITLE, COURSE_DESCRIPTION, COURSE_UNITS
FROM COURSES
ORDER BY COURSE ASC
</CFQUERY>
<cfform action=&quot;courses_view.cfm&quot; method=&quot;POST&quot;>

<cfselect name=&quot;COURSE&quot; size=&quot;10&quot;><option value=&quot;#COURSE#&quot; selected>Please select the course you would like to view.</option>
<CFOUTPUT QUERY=&quot;GetClass&quot;>
<option value=&quot;#COURSE#&quot;>#GetClass.COURSE#</option>
</CFOUTPUT>
</cfselect>

<input type=&quot;Submit&quot; value=&quot;View Course&quot;>
</cfform>
 
<cfselect name=&quot;COURSE&quot; size=&quot;10&quot;>
<option value=&quot;&quot;>Please select the course you would like to view.</option>
<CFOUTPUT QUERY=&quot;GetClass&quot;>
<option value=&quot;#COURSE#&quot;>#COURSE#</option>
</CFOUTPUT>
</cfselect>
Sylvano
dsylvano@hotmail.com
 
Hi WWebSpider,
I tried what you suggested however when I click on please select the course you would like to view it still sends me to the courses_view.cfm page and it displays empty fields from the database. In other words it still executes the query trying to fish out of the database the course information but because not course number was actually selected from the select box it displays empty information just labels such as course number, course title, course description, etc...

GRX21
 
the point here is that the return you have to loop through the query in order to display the result; try disabling the &quot;Please select the course you would like to view&quot; option:

<cfselect name=&quot;COURSE&quot; size=&quot;10&quot;>
<option disabled>Please select the course you would like to view.</option>
<CFOUTPUT QUERY=&quot;GetClass&quot;>
<option value=&quot;#COURSE#&quot;>#COURSE#</option>
</CFOUTPUT>
</cfselect>

Sylvano
dsylvano@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top