...

View Full Version : drop down list



jscript_newbie
08-01-2002, 04:20 AM
hi..

i've created three drop down list..

one to select a country
one to select a state,
& one to select a city..

this should work as follows:

initially, only the select country appears.

upon selecting a country, the select state appears based on the country.

then based on the state selected, the select city appears..

The logic works quite fine but sometimes when i've selected state, an error appears..

City is not null or an object..

Any clue? Pls help.. Am stuck for too long..

joh6nn
08-01-2002, 04:54 AM
could we see the code, or a link?

jscript_newbie
08-01-2002, 05:05 AM
sure...

fyi, i'm using coldfusion as my main prog language..

the jscript section:

<script language="javascript">

function selectOption(docForm, atype){
var docForm = document.searchform;

if (atype == 'COUNTRY'){
<cfif isDefined("form.State")>
docForm.State.selectedIndex = 0;
</cfif>

<cfif isDefined("form.City")>
docForm.City.selectedIndex = 0;
</cfif>

<cfif isDefined("form.HotelID")>
docForm.HotelID.selectedIndex = 0;
</cfif>
}

if (atype == 'STATE'){

<cfif isDefined("form.City")>
docForm.City.selectedIndex = 0;
</cfif>

<cfif isDefined("form.HotelID")>
docForm.HotelID.selectedIndex = 0;
</cfif>
}

if (atype == 'CITY'){

<cfif isDefined("form.HotelID")>
docForm.HotelID.selectedIndex = 0;
</cfif>
}

docForm.action="#Client.RootPath#index.cfm?fuseaction=home&searchType=" + atype;

docForm.submit();

}

</script>

and on each drop down list,

i have something like this:

onchange="javascript: selectOption(this.form, 'CITY');"

the name of all drop down lists has been set this way

<select name="<cfoutput>#tField#</cfoutput>" ....

and before that , i have

<cfparam name="Attributes.Fieldname" default="Attributes.City">
<cfset tField = #Evaluate("Attributes.Fieldname")#>
<cfparam name="Attributes.#tField#" default="0">
<cfset tvalue = Evaluate("Attributes.#tField#")>


Thanks in advanced.

glenngv
08-01-2002, 05:14 AM
maybe it's better to post the generated code by clicking view-source.

jscript_newbie
08-01-2002, 05:21 AM
this is the full generated source.

glenngv
08-01-2002, 09:26 AM
why do you have 2 functions named selectOption()?
also you don't have HotelID select tag which causes error 'HotelID is null or not an object' when i run it.
this is because you have the line:

docForm.HotelID.selectedIndex = 0;

the error that you mentioned did not appear.

jscript_newbie
08-01-2002, 09:32 AM
i've worked out the hotelid but the error "city is not null or an object" still exists.

try selecting a country, state, city, then select country again and then state.. now you will see the error..


there are two selectOption functions b'coz each drop down list will call the same file on change.

glenngv
08-01-2002, 10:04 AM
since the 2 functions are identical, you should remove the other.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum