| | |
Help needed on select option (multible) [list box]
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Feb 2006
Posts: 1
Reputation:
Solved Threads: 0
<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>
<input type="button" value="ADD" name="b1" onClick="add(0);">
<select name="s2" size="5" multiple>
<option value="P1">Project 1</option>
</select>
<input type="button" value="Remove" name="b3" onClick="rmv();">
<p>
New Project :
<input type="text" name="t1">
<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.
<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>
<input type="button" value="ADD" name="b1" onClick="add(0);">
<select name="s2" size="5" multiple>
<option value="P1">Project 1</option>
</select>
<input type="button" value="Remove" name="b3" onClick="rmv();">
<p>
New Project :
<input type="text" name="t1">
<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.
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
http://www.javascripttoolbox.com/lib...x/examples.php
![]() |
Similar Threads
- problem in listing directories in list box (Java)
- How to search from a database, selecting from a combo or list box in vb? (Visual Basic 4 / 5 / 6)
- Drive List Box Help Please for Error 68 (Visual Basic 4 / 5 / 6)
- list box --php issue (PHP)
- "Error in linking List box with the VB6.0 database" (Visual Basic 4 / 5 / 6)
- HTML Form not working with IE when lots of select/option boxes included. (HTML and CSS)
- HTML Form not working with IE when lots of select/option boxes included. (Web Browsers)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Firefox vs. IE-menu not working please help
- Next Thread: Form Fields
| Thread Tools | Search this Thread |
acid2 ajax ajaxcode ajaxexample ajaxhelp animate array automatically beta box bug calendar cart checkbox class codes column cookies createrange() css cursor date debugger decimal design dom download dropdown editor element embed enter error explorer firefox focus frameworks getselection google gwt hint html htmlform ie7 iframe images index internet java javascript javascripthelp2020 jawascriptruntimeerror jquery jsf jsfile jsp jump listbox maps masterpage math menu microsoft mimic mp4 object onmouseover parent paypal php player position post problem programming progressbar prototype redirect regex runtime safari scale scriptlets search select session shopping size sql text textarea toggle variables w3c website window windowofwords windowsxp wysiwyg \n





