Multiple select box

Multiple select box

Hi, I need help in code for multiple select box. The multiple select box should be populated with the db values.The selection done in the multiple select box is to be moved to the text area provided a add and remove buttons in between for moving the selected items into the text area.

View Answers

April 11, 2011 at 4:55 PM

<%@page import="java.sql.*"%>
<script>
var array = new Array();
function add() {
    var i=0;
    var ob=document.form.select;
    while(ob.selectedIndex != -1) {
        array.push(ob.options[ob.selectedIndex].value); 
        ob.options[ob.selectedIndex].selected = false;
        }
        for( i=0;i<array.length;i++){
        form.text.value+=array[i]+"\n";
        }
}
function remove(){
form.text.value="";
}

</script>
<form name="form">
<pre>
<select name="select" multiple>
<%
 Class.forName("com.mysql.jdbc.Driver").newInstance();  
 Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");  
 Statement stmt = con.createStatement();  
 ResultSet rs = stmt.executeQuery("Select * from employee");
 while(rs.next()){
%>
<option value="<%=rs.getString("name")%>"><%=rs.getString("name")%></option>
<%
 }
%>
</select>
<textarea rows="5" cols="20" name="text">

April 11, 2011 at 7:10 PM

<!DOCTYPE html>
<html>
<head>
  <style>
  div {
  color:red;
  }
  </style>
  <script src="http://code.jquery.com/jquery-1.5.js"></script>
</head>
&lt;SCRIPT LANGUAGE="JAVASCRIPT">

$(function() {
  $(".low input[type='button']").click(function(){
    var arr = $(this).attr("name").split("2");
    var from = arr[0];
    var to = arr[1];
    $("#" + from + " option:selected").each(function(){
      $("#" + to).append($(this).clone());
      $(this).remove();
    });
  });
})

</SCRIPT> 
<body>

<table>
<tr>
<td>
 <div class="container">
    <select name="itemsToChoose" id="left" size="8" multiple="multiple">
      <option value="1">item1</option>
      <option value="2">item2</option>
      <option value="3">item3</option>
      <option value="4">item4</option>
      <option value="5">item5</option>
    </select>
  </div>
</td>
<td>
  <div class="low container">
    <input name="left2right" value="add" type="button">
    <input name="right2left" value="remove" type="button">
  </div>
</td>
<td>
  <div class="container">
    <select name="itemsToAdd" id="right" size="8" multiple="multiple">
    </select>
  </div> 
</td>
</tr>
</table>

</body>
</html>

Try this....This works.....Download the js file by copy and pasting the js url in the address bar.









Related Tutorials/Questions & Answers:
Multiple select box
Multiple select box  Hi, I need help in code for multiple select box. The multiple select box should be populated with the db values.The selection done in the multiple select box is to be moved to the text area provided a add
i want to select a multiple value of check box by using onclick or onchange event without using from submission
i want to select a multiple value of check box by using onclick or onchange event without using from submission   i have 4 check box name 1)profile... the result is ok but after getting value of first box now i want a result of second box
Advertisements
multiple select values
multiple select values   can you provide an example for multiple select values for html:select tag
struts2 select tag multiple
struts2 select tag multiple  struts2 select tag multiple
select tag multiple values
select tag multiple values   I want to insert multiple values in database which i have selected from select tag
query regarding multiple select
query regarding multiple select  i have a select in jsp with multiple options.When i select multiple values i am not able to insert it into database and how do i retrieve them..please help me with an example code
select box and text box validations
select box and text box validations  hi, any one please tell me how to set validations for select box and text boxes using bean classes? thank you   Please visit the following link: http://www.roseindia.net/jsp/user
Select Box question
Select Box question   hello guys, i want to display data in a select box using foreign key,those data will come from other table which which is parent, that form will be in HTML(web ). i use oracle as database and i want using
mysql select from multiple tables
mysql select from multiple tables   how can i select the date field from multiple tables in mysql?   "UNION" can be used to select data from multiple tables in my sql... for example (SELECT * from name where `name
Dynamic select box - Ajax
in the other select box automatically.. The city details must be extracted from...Dynamic select box  Hi, I Have almost completed the task... select boxes in my page.. One is "Select a Country" and other one is "Select
dynamic select box
dynamic select box  thank u my dear friend.but i have a code like...> <select name="city"> <option>city</option>...) die("access failed"); $select=mysql_select_db("vtigercrm530"); if(!$select
dynamic select box
dynamic select box  hello friends i created a form and details of city & locations have to be come from database. if city hyderabad chosen then locations of hyderabad only appear in location selectbox.plz send code it is more
ModuleNotFoundError: No module named 'django-select-multiple-field'
ModuleNotFoundError: No module named 'django-select-multiple-field'  ...: No module named 'django-select-multiple-field' How to remove the ModuleNotFoundError: No module named 'django-select-multiple-field' error
How to change focus among multiple select boxes?
How to change focus among multiple select boxes?  Hello, I have three select boxes in three divs. All of the select boxes are focused when I click them one after the other. I want only one select box to be focused at a time
Select Box Validation in JavaScript
Select Box Validation in JavaScript In this section we will discuss about select box validation in JavaScript. Select box allows you to create drop down list... options. HTML select Box having same functionality as HTML Checkbox Fields
how to operate on select box using ajax in struts2?
how to operate on select box using ajax in struts2?  I am doing a project on struts2 in which i have a jsp page which has two select boxes like Now i want to use ajax so that when i select a district value
how to operate on select box using ajax in struts2?
how to operate on select box using ajax in struts2?  I am doing a project on struts2 in which i have a jsp page which has two select boxes like <... it by assigning to the block list select box. so please help me..its urgent
retaining the selected values in html:select multiple="true" in jsp + collection + struts
retaining the selected values in html:select multiple="true" in jsp + collection + struts  Hi, I have a multiple selection box in one of the jsp...;strong> <html:select multiple="true" style="width
Passing Multi select list box values using ajax to get values to dependent list box
Passing Multi select list box values using ajax to get values to dependent list... with multiple selection. How can i pass multiple selected values through ajax to retrieve the dependent values to the immediate next list box. Please help me
display from select box - JSP-Servlet
display from select box  I am doing a jsp project. In this jsp project i have to show the photos in one cell depending on the selection from other selection box which is in the same page. The photos are stored
Multiple select dropdown with Ajax
Multiple select dropdown with Ajax This tutorial explains how to create...; <li><a href="mutipledropdown">Multiple Select.... This file used for displays all multiple select dropdown.The code of "
jQuery Multiple Checkbox Select / Deselect
$(function(){ // add multiple select / deselect functionality..."); } }); }); jQuery Multiple Checkbox Select / Deselect In this section, you will learn how to create multiple checkbox group which select/deselect the group
how to display(update) current date and month in select box on selecting the year.
how to display(update) current date and month in select box on selecting the year.  how to display(update) current date and month in select box on selecting the year
jQuery change event with multiple select option
jQuery change event with multiple select option In this tutorial , we will discuss about 'change' event of jQuery with multiple select list & it also display the selected option. In the below example a multiple select list
approve or reject multiple selected rows using check box
approve or reject multiple selected rows using check box   Select Article Document Type Document Sub Type
How to implement ajax in struts2 to operate on select box in jsp
How to implement ajax in struts2 to operate on select box in jsp  I am doing a project on struts2 in which i have a jsp page which has 2 select boxes... by assigning to block list select box... plz help me .. its urgent .. thanx in advance
Use of Select Box to show the data from database
Use of Select Box to show the data from database       Example program using Select Box to show retrieved data from database This example will describe you the use of Select Box in a JSP
How to write a select box and id should be stored in database?
How to write a select box and id should be stored in database?  Hi, How to write a select box and select the name(devi) regarding name id(like 60...); JLabel lab=new JLabel("Select Name:"); final JComboBox combo
Not Able to select an Item in Spark Combo Box control (Adobe Flex Object) using QTP
Not Able to select an Item in Spark Combo Box control (Adobe Flex Object) using... Flex controls. But i am not able to select any item from Spark Combo Box. I tied using .Open (Its not opening the drop down list) , also i tried using Select
add text box and select list dynamically and get its value to store it into database using jsp request parameter
add text box and select list dynamically and get its value to store it into database using jsp request parameter  its very helpful when you have only... added select box also into next jsp page plz reply me as early as posssible
select one item name throug combo box than other combobox show item price
select one item name throug combo box than other combobox show item price  i have one table in database item master..if i select one item name through combo box than other combobox show item price only select item name... how i
sir plz help in design a jsp page whichis as follow username [_____] select [__>]password [_____] after selection then onlypassword text box is visible
sir plz help in design a jsp page   sir plz help in design a jsp page which is as follow username [ _ ] select [ > ] password [ _ ] after selection then only password text box is visible
jQuery 'select' form event
input box. In this Example, two input text box are given , when we select...; Click and drag the mouse to select text in the input box. </p>...jQuery 'select' form event In this tutorial, we will discuss about
select query
select query  how to write select query with where clause having multiple variables. example: i want to select the data from DB in which i want to check againest two variable in where cluase. String sql = "select * from
Selecting multiple cells and rows in AdvancedDataGrid
Selecting multiple cells and rows in AdvancedDataGrid: In this example you can see how we can select the multiple rows and cells from AdvancedDataGrid.... If it is true you can select multiple item at the same time. you will use
JavaScript Combo Box Validation
JavaScript Combo Box Validation       This application illustrates how to validate the combo box using JavaScript validation. In this example we create a combo box of different
scroll bars to list box - JSP-Servlet
scroll bars to list box  Can I add scroll bars to a list box in struts?  Hi friend, Scroll the list box in struts Two attribute set "multiple" "size". Select Tag Example Select Tag
multiple inheritance.
multiple inheritance.  hello, can java support multiple inheritance???   hi,ADS_TO_REPLACE_1 java does not support multiple inheritance
jQuery to Select Multiple CheckBox
jQuery to Select Multiple CheckBox   ... to develop the Select Multiple CheckBox  program Step 1: Create php file... { echo "Please select the checkbox.";  } ?> Step 2: Write
jQuery to Select Multiple CheckBox
jQuery to Select Multiple CheckBox   ... to develop the Select Multiple CheckBox  program Step 1: Create php file... { echo "Please select the checkbox."; } ?> Step 2: Write HTML
autocomplete displaying multiple fields
autocomplete displaying multiple fields  How can I create an autocomplete with three field (name, id, phone). Placing the phone field in the appropriate input field but selecting the name field into the 'calling' input box
multiple inheritance
multiple inheritance  Class A extends Class B but Class A also inherit Super Class Object so it is multiple inheritence give reason in support of your answer
multiple inheritance
multiple inheritance  why java doesn't support multiple inheritance? we can achieve this by using interface but not with classes? what is the main reason that java community implemented like
how to select second combobox value .
how to select second combobox value .  I requirement is , i have two combo box, i am selected first combo box value then automatically second combo box value show ,But this both combo box value i retrieves in database. please
PHP List Box Post
The PHP Post List box is used in the form. It contains multiple value User can select one or more values from the PHP list Box This PHP Post List Box is the alternate of Combo box PHP Post List Box Example <?php
Multiple Inheritance
Multiple Inheritance  Why Java Doesn't have Multiple Inheritance It is Advantage or Disadvantage.........   Hi Friend, When we extends... and inconsistencies Java does not support Multiple Inheritance. Thanks
Multiple Inheritance
Multiple Inheritance  All are saying java doesn't support multiple inheritance but by default Object class is super class for all the user defined... class so java any how do multiple inheritance? Can you please explain
SET and SELECT
SET and SELECT  hello, What is difference between SET & SELECT in sql????   hii,ADS_TO_REPLACE_1 SET : The set statement is used to the update query. SELECT : The select statement is used to display the all
select query
select query  how to retrieve a single image from mysql table using $row[] value
JList box java
Interface. It allows the multiple items in a list and In this class extend the JComponent class in Swing. We can use select item from the combo box because...JList box java We are going to describe JList box java. First of all we have

Ads