Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8

Thread: drop down list

  1. #1
    New Coder
    Join Date
    Aug 2002
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    drop down list

    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..
    Last edited by jscript_newbie; 08-01-2002 at 03:55 AM.

  • #2
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72 W. 48' 57" , 41 N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    could we see the code, or a link?
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

  • #3
    New Coder
    Join Date
    Aug 2002
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,968
    Thanks
    0
    Thanked 236 Times in 233 Posts
    maybe it's better to post the generated code by clicking view-source.

  • #5
    New Coder
    Join Date
    Aug 2002
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    this is the full generated source.
    Attached Files Attached Files

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,968
    Thanks
    0
    Thanked 236 Times in 233 Posts
    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.

  • #7
    New Coder
    Join Date
    Aug 2002
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Last edited by jscript_newbie; 08-01-2002 at 08:34 AM.

  • #8
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,968
    Thanks
    0
    Thanked 236 Times in 233 Posts
    since the 2 functions are identical, you should remove the other.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •