SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Hybrid View

  1. #1
    SitePoint Evangelist mad-onion's Avatar
    Join Date
    Aug 2000
    Location
    Land of the long white cloud
    Posts
    556
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay im sure this is easy but i cant find out how to do it...

    I want to have two select boxes: when you select say computers from select one, select two will display the sub-categories for computers, ie internet, hardware, software etc.

    I know how to add options to a select box, but how on earth do you get rid of them???

    Any help what so ever so greatfully recieved!..

    TIA
    SiteOptions >> Services :: Products :: Contact
    Developers of PHP, C++, Visual Basic, MySQL, and more!

  2. #2
    SitePoint Enthusiast
    Join Date
    Jun 2000
    Location
    MD
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I made a site just like this for a client. Here's the code you need, it's a little For Loop:

    Code:
    for (var i = document.yourformname.yourselectname.options.length; i > 0; i--)
        document.form1.product.options[i] = null;
    That's it! Let me know if you need any more help.
    Aaron Epstein
    Color Schemer, http://www.colorschemer.com

  3. #3
    SitePoint Evangelist mad-onion's Avatar
    Join Date
    Aug 2000
    Location
    Land of the long white cloud
    Posts
    556
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thankyou that is almost working...
    Escuse me for my ignorance but i dont often do any client side:

    I have this function
    function dodelete(){
    for (var i = document.all.cats.options.length; i > 0; i--)
    document.all.cats.options = null;
    }

    and this form

    <FORM NAME="all">
    <SELECT name="cats">
    <option value=1>Option One</option>
    <option value=1>Option One</option>
    </SELECT>
    <input type=button onclick="dodelete()">

    I get the error "not implimented" on the line with document.all.cats.options = null;

    Any ideas what i might be doing wrong?

    Cheers

    SiteOptions >> Services :: Products :: Contact
    Developers of PHP, C++, Visual Basic, MySQL, and more!

  4. #4
    JavaScript Guru (Big Ego) Arielladog's Avatar
    Join Date
    Jul 1999
    Location
    SC, USA
    Posts
    390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey madonions,

    You might wanna try renaming your form because when IE tries docunemt.all, it is probably not trying ot access the form called all.


    Then, you could use:


    for (j=0; j < document.formName.selectName.length; j++){
    document.formName.selectName.options[j] = null;
    }


    and that should work.

    aDog

  5. #5
    JavaScript Guru (Big Ego) Arielladog's Avatar
    Join Date
    Jul 1999
    Location
    SC, USA
    Posts
    390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I figured out whathappenned and why aepstein's code was wrong:

    At first, I did the same as him, but noticed my post was screwed up. He used the VB code to italicize something. Anyway, I just changed mine to [j] so it wouldn't italicize stuff and used the j variable in the for loop.

    aDog


  6. #6
    SitePoint Enthusiast
    Join Date
    Jun 2000
    Location
    MD
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    haha, thanks, good catch there AriellaDog. Hope you got it working Mad-Onion.
    Aaron Epstein
    Color Schemer, http://www.colorschemer.com

  7. #7
    SitePoint Evangelist mad-onion's Avatar
    Join Date
    Aug 2000
    Location
    Land of the long white cloud
    Posts
    556
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks to both of you it is now working!

    Thanks Again!!!
    SiteOptions >> Services :: Products :: Contact
    Developers of PHP, C++, Visual Basic, MySQL, and more!


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
  •