User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 361,909 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,512 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 7858 | Replies: 1
Reply
Join Date: Feb 2006
Posts: 1
Reputation: sabyasachib is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
sabyasachib sabyasachib is offline Offline
Newbie Poster

Help needed on select option (multible) [list box]

  #1  
Feb 25th, 2006
<html>
<head>
<title>Registration Page</title>
<script language="JavaScript">

function a()
{
document.f1.s2.remove(0);
}

function add(x)
{
var boxLength;
var selectedItem;
var selectedText;
var selectedValue;
var i;
var thisitem;
var isNew = true;

if ( x == 0)
{
boxLength = document.f1.s2.length;
selectedItem = document.f1.s1.selectedIndex;
selectedText = document.f1.s1.options[selectedItem].text;
selectedValue = document.f1.s1.options[selectedItem].value;
}

if ( x == 1)
{
boxLength = document.f1.s2.length;
selectedText = document.f1.t1.value;
}
//var newoption;
//document.f1.t1.value = x;//boxLength;

if (boxLength != 0)
{
for (i = 0; i < boxLength; i++)
{
if ( selectedText == document.f1.s2.options[i].text)
{
isNew = false;
break;
}
}
}

if (isNew == true)
{
document.f1.s2.options[boxLength] = new Option(selectedText,boxLength);
}
}

function rmv()
{
var selectedItem;
selectedItem = document.f1.s2.selectedIndex;
document.f1.s2.remove(selectedItem);
}

</script>

</head>
<body onLoad="a();">
<form name="f1">
Project : <br>
<select name="s1" size="5" multiple>
<option value="Project1">Project 1</option>
<option value="Project2">Project 2</option>
<option value="Project3">Project 3</option>
<option value="Project4">Project 4</option>
<option value="Project5">Project 5</option>
<option value="Project6">Project 6</option>
<option value="Project7">Project 7</option>
</select>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="button" value="ADD" name="b1" onClick="add(0);">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<select name="s2" size="5" multiple>
<option value="P1">Project 1</option>
</select>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="button" value="Remove" name="b3" onClick="rmv();">
<p>

New Project :
<input type="text" name="t1">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="button" value="ADD" name="b2" onClick="add(1);">


</form>
<body>
</html>


The above work properly. But I have a problem with this code, that is -

When I select more than one Project at a time from the Project list and click on the add button at that time only one project selected and added into another list. I want to know how I able to add more than one project at a time from the Project list to another list. Please help me as quickly as possible.

Thanks & Regards,
Sabyasachi Banerjee.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2005
Location: Kansas City, Missouri, USA
Posts: 344
Reputation: Troy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 4
Troy's Avatar
Troy Troy is offline Offline
Posting Whiz

Re: Help needed on select option (multible) [list box]

  #2  
Mar 5th, 2006
I consider myself an expert javascript coder, but when I need help, I turn to Matt Kruse. Matt offers many excellent javascript libraries. He has an excellent select box library to do exactly what you want. I use it all the time.
http://www.javascripttoolbox.com/lib...x/examples.php
Troy Wolf is the author of SnippetEdit. "Website editing as easy as it gets." IX Web Hosting
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 9:32 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC