SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Feb 2000
    Location
    District of Columbia
    Posts
    373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A really BIG request for help I apologize in advance if this is too long.

    I must be having a bad day, but I have been fighting with this piece of code for a long time, and still can't figure it out:

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">code/font><HR><pre>

    &lt;cfquery datasource="nasr" name="artcc"&gt;
    SELECT DISTINCT artcc_id_low
    FROM fix
    WHERE artcc_id_low IS NOT NULL
    &lt;/cfquery&gt;

    &lt;cfquery datasource="nasr" name="state"&gt;
    SELECT DISTINCT state_code
    FROM fix
    WHERE state_code IS NOT NULL
    &lt;/cfquery&gt;

    &lt;html&gt;
    &lt;head&gt;
    &lt;script language="JavaScript1.2"&gt;
    function whichName(obj){

    if(obj.selectType.selectedIndex == 1){
    //for artcc
    obj.selectName.length=33//&lt;cfoutput&gt;#artcc.RecordCount#&lt;/cfoutput&gt;
    obj.selectName.options[0].value="cheese"
    &lt;cfloop query="artcc"&gt;
    &lt;cfoutput&gt;
    obj.selectName.options[#CurrentRow#].value="#artcc.artcc_id_low# "
    &lt;/cfoutput&gt;
    &lt;/cfloop&gt;
    obj.selectName.options[0].text="cheese"
    &lt;cfloop query="artcc"&gt;
    &lt;cfoutput&gt;
    obj.selectName.options[#CurrentRow#].text="#artcc.artcc_id_low# "
    &lt;/cfoutput&gt;
    &lt;/cfloop&gt;
    obj.selectName.selectedIndex = 0
    return
    }
    //for state
    obj.selectName.length=59
    obj.selectName.options[0].value="cheese"
    &lt;cfoutput query="state"&gt;
    obj.selectName.options[#CurrentRow#].value="#state.state_code# "
    &lt;/cfoutput&gt;
    obj.selectName.options[0].text="cheese"
    &lt;cfoutput query="state"&gt;
    obj.selectName.options[#CurrentRow#].text="#state.state_code# "
    &lt;/cfoutput&gt;
    obj.selectName.selectedIndex = 0
    }

    &lt;/script&gt;
    &lt;/head&gt;

    &lt;body&gt;

    &lt;cfif isDefined ("URL.reason")&gt;
    &lt;font color="red"&gt;&lt;strong&gt;&lt;cfoutput&gt;#URL.reason#&lt;/cfoutput&gt;&lt;/strong&gt;&lt;/font&gt;
    &lt;cfelse&gt;
    &lt;/cfif&gt;


    &lt;form action="fix_search.cfm" method="post" name="SearchForm"&gt;

    Search by:


    &lt;!---this is the type of search box---&gt;

    &lt;select name="selectType" onChange="whichName(this.form)"&gt;
    &lt;!---&lt;option value="name"&gt;Name---&gt;
    &lt;option value="artcc"&gt;ARTCC
    &lt;option value="state"&gt;State
    &lt;/select&gt;


    &lt;!---this is the one i am trying to populate---&gt;

    &lt;select name="selectName"&gt;
    &lt;option value=""&gt;-----
    &lt;/select&gt;


    Enter Name:
    &lt;input type="text" length="15" name="keyword"&gt;


    &lt;input type="submit" value="Search NASR"&gt;&nbsp;&lt;input type="reset" value="Clear Fields"&gt;


    &lt;/form&gt;

    &lt;/body&gt;
    &lt;/html&gt;

    [/code]

    What I am trying to do:

    I have 2 queries at the top, they pull out the data from the database that I will be using to populate the second drop down. I have a dropdown box with "Name" , "State" and "ARTCC". When one of those options is selected, I want the values to change in the second dropdown to display the data I am pulling in the queries. The JavaScript At the top works, but its cheesy: as you can see, in order to start numbering from 0, I had to put some extra values in there ("CHEESE"). #CurrentRow# starts count at 1, and I am not sure how tp make it start at 0. That's question number one.

    Question number two:

    I have 3 options (name, state and artcc). Currently I can only change state and artcc. When name is selected I only want the other select box to either stay blank or display a default value, so users can enter any name in the text box below. However, no matter how I tweak the javascript above, I can't trick it into changing that one.

    I know this is a huge request, and I would really appreciate all the help you can give me. Thanks for replys in advance.

  2. #2
    SitePoint Addict
    Join Date
    Feb 2000
    Location
    District of Columbia
    Posts
    373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, scratch the first question, i got it worked out (really easy!)

    &lt;&lt;yes, it must be a long day&gt;&gt;

    The second question still stands: I can't make it work with 3 selections.

    thank you!

  3. #3
    ********* Addict DLG_1's Avatar
    Join Date
    Jun 2000
    Location
    Texas, USA
    Posts
    596
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    do you find that the "Name" selection doesn't appear?


    &lt;!-- --&gt;


    take that out.



    sam

  4. #4
    SitePoint Addict
    Join Date
    Feb 2000
    Location
    District of Columbia
    Posts
    373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no, that not the problem
    I commented that one out cuz it didnt work.

    What I am trying to do is add a third array to my JavaScript so that it would work with the "Name" selection.


Bookmarks

Posting Permissions

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