Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > 2 list-boxes with add & remove button

Reply
Thread Tools

2 list-boxes with add & remove button

 
 
Ramamoorthy Ramasamy
Guest
Posts: n/a
 
      02-04-2005
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
 
Reply With Quote
 
 
 
 
Jeff Cochran
Guest
Posts: n/a
 
      02-04-2005
On 3 Feb 2005 22:31:51 -0800, http://www.velocityreviews.com/forums/(E-Mail Removed) (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
 
Reply With Quote
 
 
 
 
craig
Guest
Posts: n/a
 
      02-11-2005
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!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove entries from add remove programs in win64 Kue2 Windows 64bit 22 01-25-2007 10:36 AM
Dynamically adding Dropdown, Text Box, Add Button and Remove Button Rocky ASP .Net Building Controls 0 11-08-2006 11:20 PM
How to remove items from add/remove list please Caractucus Potts Computer Support 5 07-03-2005 10:31 PM
Add/Remove Program Glitch: Asks If I Want To To Remove Wrong Program ? Robert11 Computer Support 6 08-02-2004 09:02 PM
how to remove software from add/remove mohnic Computer Information 2 02-07-2004 11:31 PM



Advertisments