Home Answers Viewqa JSP-Servlet Multiple select box

 
 


premika
Multiple select box
2 Answer(s)      2 years and a month 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.

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 Pages:
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
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
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
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 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 "
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
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
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
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
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
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
PHP list box
The PHP List box is used in the form. It takes input values from the user. The PHP List box contains multiple values at a time. PHP List Box Example...;  else {?>      Select your hobbie <form action
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
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
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
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
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
select option value
select option value  if i select a value of any drop down then that value should be used in a select query of the next dropdown in jsp????   Here is an example of dependent dropdown box in JSP. The values come from
select option value
select option value  if i select a value of any drop down then that value should be used in a select query of the next dropdown in jsp on same page????   Here is an example of dependent dropdown box in JSP. The values
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
nested select tag
nested select tag  My requirement is as follows suppose combobox to select country whenever i select a country it will show corresponding states in another combo box.   JSP Code 1)country.jsp: <%@page import
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
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
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
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
HI Jsp check box..!
HI Jsp check box..!  Hi all.. I want to update the multiple values of database table using checkbox..after clicking submit the edited field has to update and rest has to enable to update...please help me..its urgent
check box in jsp
check box in jsp  hey guys i am working on a web based project using jsp. In my project 1 am having 9 check boxes in 3 rows in the same form. I want to select 1 check box from each row and also i want to avoid many check box
JCombo Box problem
combo box display number of week in a selected month for the year. I am select year, month and the third combo box display the number of week. If i select any one...JCombo Box problem  I have three combo boxes First combo box display
List Box - JSP-Servlet
list box.on selecting one value in list box,i will retrieve values from database and store into another list box in same page using javascript :location.my problem is in first list box,value which i selected to get values is not displaying
how to update combobx's selected value to database with respect toselected multiple checkboxes
multiple checkboxes   suppose this if form1.jsp in which i am going...;<select name='routecombo'id='routecombo'"+i+"'>"); ResultSet rs1=ps2.executeQuery("select Route_id from table1"); while(rs1.next()) { s1
multiple keyword search - SQL
multiple keyword search  anyone can help me? i have four textfield 1)country (drop down list box) 2)city (text box) 3)gender (drop down list box) 4)Age From and Age to ((drop down list box) user may type in country
JSF Select one menu - Framework
JSF Select one menu  Hi, I am new in Jsf, I use one this is based on some table in MySQL, Data is coming in this select box, but I want also show... select on first position of select box when I run my program. But Design phase
Criteria with Multiple Tables - Hibernate
Criteria with Multiple Tables  I am using Hibernates Criteria. How to get Joins using Criteria? e.g. instead of below query i want to use criteria then How i can? select user from TeamsUserEntity
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
check box condition
check box condition  Hai, my application has two check box one for chart and another one for table.when We click chart check box download only...; <xsl:apply-templates select="head"/> <xsl:apply

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.