Click to See Complete Forum and Search --> : remove option in dropdownlist
Shampie
05-28-2003, 05:07 PM
Okay I ahve been busy and cant figure this out yet,, (buggah)
with this code I add an option to dropdownlist:
opt = form.weapon1.options;
opt[opt.length] = new Option("x", "1");
but how do i make it to remove an item?
I tried opt[opt.length-1] = new Option("x", "1");
unfortunatly this will only remove last option and only once..
I need it to remove the selected item from the list..
how do i do this?
>> click button -> remove.item.selected << to be short about what I am looking for. (in dropdown list)
tnx!
Maybe these will help
http://javascript.internet.com/forms/selection-box.html
http://javascript.internet.com/forms/selection-order.html
Jona
khalidali63
05-28-2003, 05:47 PM
He buddy..long time no see
:-)
try this link.it should address your problem..
http://68.145.35.86/skills/javascripts/CreateDynamicListBox.html
Or, in a nutshell, how to do just that:
<html>
<head>
<script language="JavaScript" type="text/JavaScript">
function remove() {
sel = document.myform.myselect;
sel.options[sel.selectedIndex] = null;
sel.options.selectedIndex = 0;
}
</script>
</head>
<body>
<form name="myform">
<select name="myselect">
<option name="one">One</option>
<option name="two">Two</option>
<option name="three">Three</option>
</select>
<input type="button" value="Remove" onclick="remove();" />
</form>
</body>
</html>
EDIT: Ah, Khalid beat me... :D
khalidali63
05-28-2003, 05:55 PM
Hey pyro,Did you test your code with IE and NS?..just curious...
Shampie
05-29-2003, 04:22 AM
as usual you guys still kick ass :)
If i got some space ill upload the thingy I am making..
Shampie
05-29-2003, 05:06 AM
is there also a possibilty to synchronize 2 droplists? so they both are always the same? when I remove one from A the same item will be removed from B?
khalidali63
05-29-2003, 08:12 AM
Yes you can do that...if you have multiple object you want the same changes to be applied on them.You will have to make sure that what ever changes you make to one are made other programmatically,not a big job.
Shampie
05-29-2003, 10:06 AM
and how is this done?
Shampie
05-29-2003, 10:09 AM
or is this done by adding a line like :
something happens to A
something happens to B <- add to all coding?!
khalidali63
05-29-2003, 10:09 AM
Lets do this...
yo already have the code to do one art here right?.
Now what I'd recomend do whatever you think should be there ( no problems if doesn't work),
once you have that,then show me the code....I'll guide you through fixing it.
Shampie
05-29-2003, 10:14 AM
hmm time to read trough 30 pages of scripting? :)
khalidali63
05-29-2003, 10:16 AM
Nope, not really...:-)
My point is that if you tried it your self a bit,it be more clear to you how it works..
Shampie
05-29-2003, 02:53 PM
I actually got it fixed! unbelievable!
the oddest part is it fell into its own place without to much scripting... did you know more about that?
Shampie
05-29-2003, 02:55 PM
hey was it you btw who wanted my avanter?
khalidali63
05-29-2003, 03:12 PM
I might have mentioned that...sice its "Mapple Leaf" ya know..:-)
but its ok now..I like my walking dude..
[font=arial]Khalid, while we're on the subject (and off the topic), where did you get your avatar? I need one like that. :p /font]
Jona
khalidali63
05-29-2003, 07:59 PM
Hey Jona,
I found it somewhere over the net,actually quite a few years back.
It compensates for my lazy ass,since I need to walk and eat salad..:-)(yikes)
Hotscripts.com PHP section?