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 7 of 7

Thread: combo boxes

  1. #1
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    combo boxes

    Been tryin the double combo box script with *some* success but havin difficulty with two things. First I want to abandon the GO button entirely and have the second field directly link to the URL without having to click - how'd'I do that?
    Second, some of my links from the *first* combo box have only a single option, and currently have single new option in the second field with CLICK GO in it - not very pretty, so how can I make selected options from first box simply not bother with the second one and just go straight to the URL?
    Does that make sense?
    Mike

  • #2
    Regular Coder
    Join Date
    Jul 2002
    Location
    Western US
    Posts
    169
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Using the onChange funtion of the second select box will allow you to call a function and then go to the url.

    <select name="category" onChange="setSubCategory()">

    As for having it go if there is only 1 and 1, you can check to see how long the options list is, and then check the length of the second select box to be equal to 1 as well.

    document.childForm.category.length

    ShriekForth

  • #3
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    yeah, wot he said

    ummmm, pardon?
    i didnt get a bleedin' word of that
    mike

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    Round Rock, Texas
    Posts
    443
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What the programmer said was...

    Let's say you have this:
    Code:
    <select name="gohere" ... onChange="GoForth (this)>
                Where do you want to go?
       <option value="http://www.radarbob.com">
                      RadarBob web site</option>
       <option value="http://www.apple.com"> 
                      Apple web site</option>
    </select>

    Code:
    function GoForth (whereIwantToGo) {
       for (var i=0; i<whereIwantToGo.length; i++)  {
    
          if (whereIwantToGo.options[i].selected) {
             window.location= whereIwantToGo.options[i].value;
          } 
       }
    }  // function GoForth()

  • #5
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy parlez vous franglais?

    anyone here an interpreter? im sorry guys - Ive no doubt youve both given me perfect solutions, but you may as well be speaking ancient greek for all Im getting from it. Could either of you post an actual example which I could cut and paste and figure out from there?
    Sorry to be such a halfwit
    Mike

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Location
    Round Rock, Texas
    Posts
    443
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ask and ye shall receive:
    Here is a complete, working HTML page. When you select from the drop down list you are taken immediately (w/out a pesky GO button to click) to that web site.

    I added one tweak from my code above. the first <option> in the list is a prompt to select from the list. Otherwise, in short, it wouldn't work so good.

    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

    <
    html>
    <
    head>
    <
    title>Page title</title>

    <
    script language="JavaScript" type="text/javascript">
    <!--
    function 
    GoForth (whereIwantToGo) {
       for (var 
    i=0i<whereIwantToGo.lengthi++)  {

          if (
    whereIwantToGo.options[i].selected) {
             
    window.locationwhereIwantToGo.options[i].value;
          } 
       }
    }  
    // function GoForth()
    //-->
    </script>
    </head>


    <body>
    <form>
    <b>Where do you want to go?</b><br>
    <select name="gohere" onChange="GoForth(this)">
       <option value="" SELECTED>Select a site from this list</option>
       <option value="http://www.hp.com">
                      hewlet Packard web site</option>
       <option value="http://www.apple.com"> 
                      Apple web site</option>
    </select>

    </form>


    </body>
    </html> 
    Last edited by RadarBob; 07-26-2002 at 07:15 PM.

  • #7
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    many thanks n e way (sic)

    Before I forget bob, your URL shows up a "cannot display" error.
    Right, back to case in hand. Thanks bob, and others, for the obvious time and effort in helping me - as you can see this isnt my forte, but if you need any help in Flash lemme know
    The HTML you provided did the trick, but not as I really wanted - what I was after was removing the Go button from the TWIN drop down fields, and the page you supplied wont integrate with a twin box. I also fancied the primary field spotting that for some options the secondary field had only one option and going straight to the URL obviating the need for a second click.
    Whatever, that was only an aesthetic consideration, and bearing in mind the help youve already provided I wont ask more and will simply use it 'as is' out of the box! Thanks again for your help(s), and BTW i agree with you re: the first option being a dummy irrespective of whether theres a Go button or not, it just looks better that way
    regards
    Mike


  •  

    Posting Permissions

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