/    Sign up×
Community /Pin to ProfileBookmark

Help move item list

?Hi guyz.
The current version works fine… And I was not able to make two things on this js.
First one, if there is a same item on the boxes, the js must not move over item.(no duplicates on boxes)
Second, if the move item is ” All”, the right box must not contain other items. Else move item is other than ” All” then right box must not have ” All”

Your help appreciated.

[code]
<style>
select { width: 200px; float: left; }
#Toolbar { width: 50px; float: left; text-align: center; padding-top: 30px; }
#Toolbar input { width: 40px; }
</style>
<script>
function Move(inputControl)
{
var left = document.getElementById(“Left”);
var right = document.getElementById(“Right”);
var from, to;
var bAll = false;
switch (inputControl.value)
{
case ‘<<‘:
bAll = true;
// Fall through
case ‘<‘:
from = right; to = left;
break;
case ‘>>’:
bAll = true;
// Fall through
case ‘>’:
from = left; to = right;
break;
default:
alert(“Check your HTML!”);
}
for (var i =from.length-1; i >=0; i–)
{
var o = from.options[i];
if (bAll || o.selected)
{
from.remove(i);
try
{
to.add(o, null); // Standard method, fails in IE (6&7 at least)
}
catch (e)
{
to.add(o); // IE only
}
}
}
}
</script>
<title>Untitled Document</title>
</head>

<body>

<select id=”Left” multiple=”multiple” size=”10″>
<option value=” All”> All</option>
<option value=”BK”>BK</option>
<option value=”QN”>QN</option>
<option value=”SI”>SI</option>
</select>

<div id=”Toolbar”>
<input type=”button” value=”&gt;” onclick=”Move(this)”/>
<input type=”button” value=”&gt;&gt;” onclick=”Move(this)”/>
<input type=”button” value=”&lt;&lt;” onclick=”Move(this)”/>
<input type=”button” value=”&lt;” onclick=”Move(this)”/>
</div>

<select id=”Right” multiple=”multiple” size=”10″>
<option value=”SI”>SI</option>
</select>
</body>
[/code]

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @emmim44 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...