Closed Thread Icon

Preserved Topic: select tag (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=18143" title="Pages that link to Preserved Topic: select tag (Page 1 of 1)" rel="nofollow" >Preserved Topic: select tag <span class="small">(Page 1 of 1)</span>\

 
lallous
Paranoid (IV) Inmate

From: Lebanon
Insane since: May 2001

posted posted 07-27-2001 16:14

hi!

i'm not really sure how to manipulate items between two select tags.
actualy, I have two select tags with multiselect, and i have two buttons,
select tag 1 is called sel_A and the other is sel_B
now sel_A have a list of names,
I want the user to press on a button labeled ">>" to transfer selected item from sel_A to sel_B
and if he presses "<<" it will transfer item from sel_B to sel_A,

so basically, how can i delete items from a select object? and how can i add?

document.form1.sel_A.options[...selectedIndex] = null ? (this will delete an item?)
and how to add to sel_B?
i tried also: sel_B.options.length++; sel_B.options[sel_B.options.length].value = "new value read from A";
and seems doesn't work...any suggestions?

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 07-28-2001 02:55

Fuck I don't have my ref book handy,

I believe what it is is

optionLiast.options[num] = new Option(Name,Value,note1,note1);


The last two values are optianal boolean (true/false) and I only remember one.
One makes the option selected, I can't remember what the other one does.



:[ Computers let you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila. ]:

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 07-28-2001 09:24

--- start copy/paste ---

Syntax

To create an option to add to an existing Select object:

optionName = new Option([text, value, defaultSelected, selected])

To add the new option to an existing Select object:

selectName.options[index1]=optionName

To delete an option from a Select object:

selectName.options[index1] = null

To use a Select object's properties and methods:

1. selectName.propertyName
2. selectName.methodName(parameters)
3. formName.elements[index].propertyName
4. formName.elements[index].methodName(parameters)

To use an option's properties:

1. selectName.options[index1].propertyName
2. formName.elements[index2].options[index1].propertyName
3. optionName.propertyName

Parameters

optionName is either the name of a new object or a property of an existing object. When using Option properties and methods, optionName is either the name of an existing Option object or a property of an existing object.

text specifies the text to display in the select list. You can access this value using the text property.

value specifies a value that is returned to the server when the option is selected and the form is submitted. You can access this value using the value property.

defaultSelected specifies whether the option is initially selected (true or false). You can access this value using the defaultSelected property.

selected specifies the current selection state of the option (true or false). You can access this value using the selected property.

selectName is the value of the NAME attribute of a Select object.

formName is either the value of the NAME attribute of a Form object or an element in the forms array.

index is an integer representing a Select object on a form or the name of a Select object as specified by the NAME attribute.

index1 is an integer representing an option in a Select object.

index2 is an integer representing a Select object on a form.

propertyName is one of the properties listed below.

methodName is one of the methods listed below.

--- end copy/paste ---

lallous
Paranoid (IV) Inmate

From: Lebanon
Insane since: May 2001

posted posted 07-30-2001 09:50

I have made this routine out of the help of mr.Max and bitdamaged. Thanks guys.

code:
function lbTOlb(fa, fb, nocondition)
{
fao = fa.options;
fbo = fb.options;

restart = true;

while (restart)
l_while:
{
for (i=0; i<fb.options.length; i++)
{
if (fb.options[i].selected &#0124; &#0124; nocondition)
{
fao[fao.length] = new Option(fbo[i].text, fbo[i].value, false);
fbo[i] = null;
restart = true;
break l_while;
}
}
restart = false;
}
}

// examples....

function buyselected()
{
lbTOlb(document.myform.f_a, document.myform.f_b);
}

function returnselected()
{
lbTOlb(document.myform.f_b, document.myform.f_a);
}

function buyall()
{
lbTOlb(document.myform.f_a, document.myform.f_b, true);
}

function returnall()
{
lbTOlb(document.myform.f_b, document.myform.f_a, true);
}





[This message has been edited by lallous (edited 07-30-2001).]

« BackwardsOnwards »

Show Forum Drop Down Menu