Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet Multiple select box

Have Programming Question? Ask it here!
 
 
 


premika
Multiple select box
2 Answer(s)      3 years and 3 months ago
Posted in : JSP-Servlet


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.


Advertisement
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 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 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 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
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
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
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
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 "
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
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
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
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
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
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
jQuery to Select Multiple CheckBox
jQuery to Select Multiple CheckBox   ... the Select Multiple CheckBox  program Step 1: Create php file to that prints..._name, ' ', "\n"; } } else { echo "Please select
jQuery to Select Multiple CheckBox
jQuery to Select Multiple CheckBox   ... the Select Multiple CheckBox  program Step 1: Create php file to that prints..._name, ' ', "\n"; } } else { echo "Please select
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
SET and SELECT
SET and SELECT  hello, What is difference between SET & SELECT in sql????   hii, SET : The set statement is used to the update query. SELECT : The select statement is used to display the all data's in the table
select query
select query  how to retrieve a single image from mysql table using $row[] value
Column select
Column select   How i fetch Experience wise resume?   ... or no. Then using the query select * from resumes where experience='yes', fetch all the data...("jdbc:mysql://localhost:3306/test", "root", "root"); String query = "select * from
Select from select list + display
Select from select list + display  i have a select list containing... select EmpCode from the select list, the corresponding EmpName and DeptName should...;/div> <tr><td><b>Select:</b></td><td><
multiple inheritance.
multiple inheritance.  hello, can java support multiple inheritance???   hi, java does not support multiple inheritance
combo box
combo box  Hi, [_|] dropdown box... a screen like this using jsp-servlet(or DAO,DTO),in that drop down box i should get... to that user in left list.when we select module from left list and click INCLUDE button
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
dialog box
numeric choice to select answers  hello. write an application that displays a series of at least four interview questions and each question should... of the interview, use a dialog box to ask whether the user wants to - enter another set
input box
input box  give me the code of input box in core java
input box
input box  give me the code of input box in core java
HTML in the box
HTML in the box  Can I use any HTML in the box
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
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
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
 

 

 

DMCA.com