SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Under Construction Poop_Shoot's Avatar
    Join Date
    Jul 2003
    Location
    Sacramento, CA
    Posts
    330
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Modify Select Options?

    Is it possible to modify options in a select tag! Basically adding and removing the options tags dynamically as need by the script! I would rather it do it that way than the obj.options[i].text that I am using now! I tried obj.createElement("OPTION" ) but had no success! Thanx

    Jon

  2. #2
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Code:
    function setMenu2(whichtype) {
    var xarray=rhythmselection[whichtype];
    x=xarray.length;
    for(i=0;i<x;i++) {
    document.myform.menu2.options[i] = new Option((xarray[i]),(xarray[i].replace(/\s+/g,'')));} 
    }
    
    switch(selectValue){
     case rhythmtype[0]:setMenu2(0);XMLFolder=rhythmtype[0]+"/";break;  
     case rhythmtype[1]:setMenu2(1);XMLFolder=rhythmtype[1]+"/";break; 
     case rhythmtype[2]:setMenu2(2);XMLFolder=rhythmtype[2]+"/";break; 
     case rhythmtype[3]:setMenu2(3);XMLFolder=rhythmtype[3]+"/";break;
     case rhythmtype[4]:setMenu2(4);XMLFolder=rhythmtype[4]+"/";break;
     case rhythmtype[5]:setMenu2(5);XMLFolder=rhythmtype[5]+"/";break;
     case rhythmtype[6]:setMenu2(6);XMLFolder=rhythmtype[6]+"/";break;}
    thats what I use to change a second select, so I think the main line is
    Code:
    document.myform.menu2.options[i] = new Option((xarray[i]),(xarray[i].replace(/\s+/g,'')));}
    which should be able to be change for your needs. I hope it helps
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if


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
  •