473,473 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

2 list-boxes with add & remove button

Hi all,

I would like to create a page with VBscript and ASP which will contain
two list-boxes one in the left side and the other in the right side
with two buttons namely "Add>>" and "<<Remove" so that if the user
selects a value listed in the left side list-box and presses "Add>>"
then that selected value should go inside the right side list-box.
Similarly if the user selects a value listed in the right side
list-box and after clicking "<<Remove" then that selected value should
go back to the left side list-box.

Can anyone provide me the code?

Some useful tutorial links explaining the above scenario can also be
given.

Any help is much appreciated and thanks in advance.

regards,
Ramamoorthy
Jul 22 '05 #1
2 3043
On 3 Feb 2005 22:31:51 -0800, ra******@gmail.com (Ramamoorthy
Ramasamy) wrote:
I would like to create a page with VBscript and ASP which will contain
two list-boxes one in the left side and the other in the right side
with two buttons namely "Add>>" and "<<Remove" so that if the user
selects a value listed in the left side list-box and presses "Add>>"
then that selected value should go inside the right side list-box.
Similarly if the user selects a value listed in the right side
list-box and after clicking "<<Remove" then that selected value should
go back to the left side list-box.

Can anyone provide me the code?


ASP wouldn't be the proper technology for this, you'd want to do this
on the client side. Check a VBScript or Javascript group, and keep in
mind that VBScript has limited support on non-Windows platforms.

Jeff
Jul 22 '05 #2
This is all the code you need...

<script language="JavaScript">
<!-- hiding
function dosubmit() {}

function deleteOption(object,index) {
object.options[index] = null;
}

function addOption(object,text,value) {
var defaultSelected = true;
var selected = true;
var optionName = new Option(text, value, defaultSelected, selected)
object.options[object.length] = optionName;
}

function copySelected(fromObject,toObject) {
for (var i=0, l=fromObject.options.length;i<l;i++) {
if (fromObject.options[i].selected)
addOption(toObject,fromObject.options[i].text,fromObject.options[i].valu
e);
}
for (var i=fromObject.options.length-1;i>-1;i--) {
if (fromObject.options[i].selected)
deleteOption(fromObject,i);
}
}

function copyAll(fromObject,toObject) {
for (var i=0, l=fromObject.options.length;i<l;i++) {
addOption(toObject,fromObject.options[i].text,fromObject.options[i].valu
e);
}
for (var i=fromObject.options.length-1;i>-1;i--) {
deleteOption(fromObject,i);
}
}
function selectAll(fromObject) {
for (var i=0, l=fromObject.options.length;i<l;i++) {
//addOption(toObject,fromObject.options[i].text,fromObject.options[i].va
lue);
fromObject.options[i].selected = true;
}
}
// stop hiding -->
</script>


<table width = "100%" border = "0">
<tr>
<td>
<select size="15" name="ExtraAreas" class="inpt" multiple
style="width:180">
<%
'call stuff from databse her
%>
<option value="<!-- db value -->"><!-- db value --></option>
</select>
</td>

<td align = "center">
<input type="button" value="Add &raquo; "
onClick="copySelected(this.form.ExtraAreas,this.fo rm.ExtraAreas1),
dosubmit(ExtraAreas1)" class = "button">
<input class = "button" type="button" value="&laquo; Remove"
onClick="copySelected(this.form.ExtraAreas1,this.f orm.ExtraAreas),
dosubmit(ExtraAreas)">
</td>
<td class = "tableNorm">
<select size="15" name="ExtraAreas1" class="inpt" MULTIPLE
style="width:180"></select>
</td>
</tr>
</table>

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: John Hunter | last post by:
I am writing a python extension module and have a reference counting question My function looks like static PyObject * pokereval_seven_cards(PyObject *self, PyObject *args) { int i;
7
by: Klaus Neuner | last post by:
Hello, I need a function that converts a list into a set of regexes. Like so: string_list = print string_list2regexes(string_list) This should return something like:
9
by: kazio | last post by:
Hello, So, I need to have double linked, circular list (last element point to the first one and first one points to the last one). I thought maybe I could use list container from STL, but...
6
by: massimo | last post by:
Hey, I wrote this program which should take the numbers entered and sort them out. It doesnąt matter what order, if decreasing or increasing. I guess I'm confused in the sorting part. Anyone...
10
by: Kent | last post by:
Hi! I want to store data (of enemys in a game) as a linked list, each node will look something like the following: struct node { double x,y; // x and y position coordinates struct enemy...
3
by: chellappa | last post by:
hi this simple sorting , but it not running...please correect error for sorting using pointer or linked list sorting , i did value sorting in linkedlist please correct error #include<stdio.h>...
0
by: drewy2k12 | last post by:
Heres the story, I have to create a doubly linked list for class, and i have no clue on how to do it, i can barely create a single linked list. It has to have both a head and a tail pointer, and...
0
by: Atos | last post by:
SINGLE-LINKED LIST Let's start with the simplest kind of linked list : the single-linked list which only has one link per node. That node except from the data it contains, which might be...
0
by: saijin | last post by:
I'm planning to call a list of data from an XML file but when I duplicate the content inside the <data></data> it is not showing anything Here's the ActionScript 3.0 import...
7
by: QiongZ | last post by:
Hi, I just recently started studying C++ and basically copied an example in the textbook into VS2008, but it doesn't compile. I tried to modify the code by eliminating all the templates then it...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.