Working with cfselect in cfform

There was a post on an adobe forum wondering how to go about doing this, they state that they go on and on looking for how to do this, and so i’m gonna help’em out…

View the example

Download the File

the basis of what they want to do is rather easy, but the error handling in cfform when the format is flash, is SOOOOO HARD TOOO DEBUG!

1. Call the setUp() function in the onload=”setUp();” in the beginning form tag that your going to create further into the lesson.

<cfform name=“Performance”

timeout=“500” height=“800” width=“800”

format=“flash” skin=“haloSilver”

action=“action.cfm” method=“post”

onload=“setUp();”>

2. Create a cfformitem type=”script” right under the cfform tag and create your setUp function as well as another function we are going to call, when one of your select boxes change.

<cfformitem type=“script”>

public function setUp():Void{

School.enabled = false;

}

public function changeStatus(status):Void{

if (Title.selectedItem.data == 1){

   //this is case sensitive so be careful

School.enabled = status;

}

}

</cfformitem>

3. Create Your two cfselects, and call the changeStatus() function in the onChange=”” event of the first one.

<cfselect name=“Title”

label=“Title” width=“200”

tooltip=“Please enter appropiate title.”

required=“Yes” onChange=“changeStatus(true)” >

<option>Select</option>

<option value = “0”>

Asso. & Asst. Deans

</option>

<option value = “1”>

Asso. & Asst. Provost & VPs

</option>

<option value = “2”>

Campus Directors

</option>

</cfselect>

<cfselect name=“School” width=“200” required=“Yes” >

<option>

Select

</option>

<option value=“1”>

Dyson

</option>

<option value =“2”>

Education

</option>

</cfselect>

</form>

Hope this helps… take a look at the example.

3 comments on this post.
  1. Dave Dugdale:

    I like all the examples you have of cfform on this site. Nice work.

    I am trying to figure out if I can use cfform for two selection boxes. The selection box in the left has city names and the one on the right has the city names that you have selected from the left side.

    I am trying to do with with html and JS but I am having a heck of a time getting it to work right.

    I can’t seem to find any examples of this because I am not sure what to search for.

    Dave

  2. admin:

    @Dave,

    first off, thanks for reading the blog…

    second… try looking up “multiple select boxes with cfform”

    or here is a link… asfusion has GREAT GREAT EXAMPLES of cfform

    http://www.asfusion.com/blog/entry/two-selects-related-in-cfform

  3. Dave Dugdale:

    Thanks for the example. I actually saw that one last night but it is not exactly what I am looking for.

    The best way to describe it is with a screenshot of what I do not have working:

    http://www.solardave.com/wp-content/uploads/2008/07/target-locations.png

    Dave

Leave a comment