Dunno if this is what you want, but:

<script language="javascript">
        function changeIt(select1, select2)
        {
                if (document.getElementById(select1).selectedIndex > 0)
                {
                        document.getElementById(select2).selectedIndex = 1;
                }
        }
</script>
<form>
        <select id="A" onchange="changeIt('A','B');">
                <option>1</option>
                <option>2</option>
        </select>
        <select id="B">
                <option selected>A</option>
                <option>B</option>
        </select>
</form>

Changes the index of B from 0 to 1 if you change the index of A to anything
higher than 0 (1 in this case).

--  Ben Doom
    Programmer & General Lackey
    Moonbow Software, Inc

: -----Original Message-----
: From: Deanna Schneider [mailto:[EMAIL PROTECTED]
: Sent: Tuesday, March 04, 2003 11:21 AM
: To: CF-Community
: Subject: Re: grrr....javascript
:
:
: Nope. The error I get is selectOne.1 is null or not an object, which is
: essentially the same error I was getting before. It doesn't seem to be
: changing the variable names to the real names of the select boxes that I'm
: trying to pass in.
:
: -d
:
:
: ----- Original Message -----
: From: "jon hall" <[EMAIL PROTECTED]>
: To: "CF-Community" <[EMAIL PROTECTED]>
: Sent: Tuesday, March 04, 2003 9:28 AM
: Subject: Re: grrr....javascript
:
:
: > Assuming select1 and select2 are the names of the select boxes, and
: > this is the first form on the page, this should work...no guarantees
: > though :)
: >
: > function changeIt(select1, select2){
: >    selectOne = document.forms[0][select1];
: >    selectTwo = document.forms[0][select2];
: >
: >    if (selectOne[1].selected)
: >       selectTwo.selectedIndex = 1;
: > }
: >
: > --
: >  jon
: >  mailto:[EMAIL PROTECTED]
: >
: > Tuesday, March 4, 2003, 10:01:39 AM, you wrote:
: > DS> Hi folks,
: > DS> I'm in a foul mood this morning, and I'm trying to figure out this
: javascript thing. That's a
: > DS> bad combination for me. So, I decided to ask for help. Here's the
: basic script that works (with the hardcoded names of the select boxes).
: > DS> <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
: > DS> <!--
: > DS> function changeIt(select1, select2){
: > DS>  var form = document.forms[0];
: > DS>  if (form.a1best[1].selected) {
: > DS>   form.a1when.selectedIndex = 1;}
: > DS>  }
: > //-->>
: > DS> </SCRIPT>
: >
: > DS> Basically, I want to be able to change the second select box if they
: choose the first item in the first select box. But, when I try use the
: variable names (select1, select2), it fails. Shouldn't
: > DS> I be able to call the script like so: onChange="changeIt(a1best,
: a1when)" and change the hardcoded references in the script above
: to select1
: and select2 and have it work?
: >
: > DS> ---------------------------------------------------------
: > DS> Deanna Schneider
: > DS> UWEX-Cooperative Extension
: > DS> Interactive Media Developer
: > DS>
: >
: 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=5
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=5
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.5
                                

Reply via email to