You are trying to run ColdFusion on the client. It does not
work there,
ColdFusion only works on the server. Once the http request
has been
sent to the client, you use client technology like
JavaScript. If you
want to query the sever without doing a page refresh, you are
looking at
AJAX/FLEX type technology.
lvbao wrote:
> Hello,
>
> I have a select dropdown which submit to a hidden Iframe
and pass the value
> back to the Javascript function 'handleResponse' below.
In this function I
> want to populate another dropdown select based on the
value passed from the
> hidden Iframe.
>
>
> I've tried to use Coldfusion in the javascript to
populate the dropdown but I
> struggle to make it work. The javascript would look like
this:
> document.formName.fieldName.options
= new Option(i+1)
>
> if I replace (i+1) with a Coldfusion code, it gives me
error:
> document.apptform.available_time.options = new
> Option(<cfoutput>#atime
#</cfoutput>)
>
> Can someone please tell me what I am doing wrong here.
Please see the script
> below. Thank you in advance.
>
>
> function handleResponse(currVal) {
>
>
> <cfset atime = StructNew()>
> <cfset a = StructInsert(atime, 1, "9:30 AM", 1)>
> <cfset a = StructInsert(atime, 2, "10:00 AM", 1)>
> <cfset a = StructInsert(atime, 3, "10:30 AM", 1)>
> <cfset a = StructInsert(atime, 4, "11:00 AM", 1)>
> <cfset a = StructInsert(atime, 5, "11:30 AM", 1)>
> <cfset a = StructInsert(atime, 6, "12:00 PM", 1)>
> <cfset a = StructInsert(atime, 7, "12:30 PM", 1)>
> <cfset a = StructInsert(atime, 8, "1:00 PM", 1)>
> <cfset a = StructInsert(atime, 9, "1:30 PM", 1)>
> <cfset a = StructInsert(atime, 10, "2:00 PM", 1)>
> <cfset a = StructInsert(atime, 11, "2:30 PM", 1)>
> <cfset a = StructInsert(atime, 12, "3:00 PM", 1)>
> <cfset a = StructInsert(atime, 13, "3:30 PM", 1)>
> <cfset a = StructInsert(atime, 14, "4:00 PM", 1)>
> <cfset a = StructInsert(atime, 15, "4:30 PM", 1)>
> <cfset a = StructInsert(atime, 16, "5:00 PM", 1)>
> <cfset a = StructInsert(atime, 17, "5:30 PM", 1)>
> <cfset a = StructInsert(atime, 18, "6:00 PM", 1)>
> <cfset a = StructInsert(atime, 19, "6:30 PM", 1)>
> <cfset a = StructInsert(atime, 20, "7:00 PM", 1)>
>
>
> <cfset timelist = arrayToList(structSort(atime,
"numeric"))>
> <!---
> <cfloop list='#timelist#' index='num'>
> <cfset dropdown = "<option
value='#num#'>#atime
#</option>">
> </cfloop>
> --->
> if (currVal == 'all') {
>
>
> <!---alert("<cfloop list='#timelist#'
> index='num'><cfoutput>#atime
#</cfoutput></cfloop>")--->
>
>
> document.apptform.available_time.options.length = 0
>
for(i=0;i<<cfoutput>#listlen(timelist)#</cfoutput>;i++)
{
>
>
> document.apptform.available_time.options = new
> Option(<cfoutput>#atime#</cfoutput>)
> //document.write('<option value=' + i + '>' + i +
'</option>');
> }
>
>
> } else {
> alert("testing")
> // this will query the database to select the right
option.
> }
> }
>