remove item from list box using java script

remove item from list box using java script

View Answers

October 22, 2008 at 1:20 PM

Hi friend,

Code to remove list box item using java script :

<html>
<head>
<title>Add or Remove Options in Javascript</title>
<script language="javascript" >

function addItem(selectbox,text,value )
{
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
selectbox.options.add(optn);
}


function addItems(selectbox){
addItem(document.list.item, "One","One");
addItem(document.list.item, "Two","Two");
addItem(document.list.item, "Three","Three");
addItem(document.list.item, "Four","Four");
addItem(document.list.item, "Five","Five");
addItem(document.list.item, "Six","Six");

}


function removeItems(selectbox)
{
var i;
for(i=selectbox.options.length-1;i>=0;i--)
{
//selectbox.options.remove(i);
selectbox.remove(i);
}
}

function removeItem(selectbox)
{
var i;
for(i=selectbox.options.length-1;i>=0;i--)
{
if(selectbox.options[i].selected)
selectbox.remove(i);
}
}

</script>
</head>

<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000" onload="addItems()";>
<FORM name="list">
<SELECT id="item" NAME="item" MULTIPLE size=6 width=10>
</SELECT><br>
<input type=button onClick="removeItem(item)"; value='Remove Selected Item'>
<input type=button onClick="removeItems(item)"; value='Remove All Item'>
</form>
</body>

</html>


For read more information on Javascript visit to :

http://www.roseindia.net/javascript/

Thanks









Related Tutorials/Questions & Answers:
remove item from list box using java script - Java Beginners
remove item from list box using java script  remove item from list box using java script  Hi friend, Code to remove list box item using java script : Add or Remove Options in Javascript function addItem
remove duplicates from list in java using set
remove duplicates from list in java using set  Hi, I have a list... this? Tell me program for the removal of duplicates from list in java using set... duplicates from list in java using set: import java.util.Arrays; import java.util.List
Advertisements
how to insert list box in java script dynamically and elements retrieving from database like oracle
how to insert list box in java script dynamically and elements retrieving from database like oracle  hi all, how can i insert elements into java script list box retrieving from Database. whenever I insert any element in the Db
how to insert list box in java script dynamically and elements retrieving from database like oracle
how to insert list box in java script dynamically and elements retrieving from... box in javascript when elements retrieving from database.. That is whenever I insert new course in a table.. It should be seen in my list box..ADS
How to obtain the selected data item from a list box when listbox contains objects wrapped under Arraylist?
How to obtain the selected data item from a list box when listbox contains... want to copy the selected item(one at a time) from the list box to the text box. I... and a text box. I am sending an Array List object from a servlet to this jsp
java script text box
java script text box  hi, I created a button when i click... in alert). i also want the text box should generate in front of NEW button(next/prev) and after it submits it should show before the NEW line.dont add again two box
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
Populate a combo box using data from a database
Populate a combo box using data from a database  Hi Guys, In need... to the client using ajax, and then populate the combo box, I must'nt reload... combo box which will then load the next combo box values, now i know how
How to access the "Add/Remove Programs" list in Control Panel using Java Program? - Java Beginners
How to access the "Add/Remove Programs" list in Control Panel using Java Program?  Dear Sir, I'm very interested in creating java programs innovatively. I've planned to write a java coding for accessing the Add/Remove
remove punctuation from string in java
remove punctuation from string in java  Hi, I want to remove punctuation in text from Java program. How to remove punctuation from string in java... String str = "Welcome to the Java Programming,; ???? .. Here you
delete an item from database
delete an item from database  how to delete an item from the database using jsp
barcode reader using java script
barcode reader using java script  Hai all, I need code for one application in java and java script my requirement is, Scanning data directly... in the appropriate field that is to receive the data from the scan and the trigger is pressed
write a program to remove the element from hashset using keyboard.
write a program to remove the element from hashset using keyboard.  write a program to remove the element from hashset using keyboard
Need to remove duplicated rows from excel using apache POI API
Need to remove duplicated rows from excel using apache POI API  Hi... duplicated rows from excel sheet by using apache poi api oe jxl api... duplicated rows from excel. same as below i need to do by using apache POI
how to make drop down list in JSF & fetch data Item from database
how to make drop down list in JSF & fetch data Item from database  how to make drop down list in JSF & fetch data Item from database
Scrolling List Box. - Java Beginners
Scrolling List Box.  How can is make a list box scrollable by using method ? Please give me the code snipetts
Scrolling List Box. - Java Beginners
Scrolling List Box.  How can is make a list box scrollable by using method ? Please give me the code snipetts
jsp list box - Java Beginners
jsp list box  I have two list boxs. the values for the first list box is retrieved from the mysql database. I want to fill the second list box selected item from the database. Please help me in this regard. Your help
Scrolling List Box. - Java Beginners
Scrolling List Box.  How can is make a list box scrollable by using... ListSelectionListener { private JList list; private DefaultListModel listModel..."); //Create the list and put it in a scroll pane. list = new
retrive the data from access database to drop down list box in jsp
retrive the data from access database to drop down list box in jsp  hai, im new to jsp now im using the jsp along with access database.in table i load all the data's i need to retrive the data from database to dropdown list box
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 box  Hi, I have a jsp page which has 3 dependent list boxes... the dependent values to the immediate next list box. Please help me
Without Using Form in Java Script
Without Using Form in Java Script  HOw to Reset the data in javascript without using form tag
how to remove the column from a java web page
how to remove the column from a java web page  i have a web page with account#, qtr, year if i want to remove the year column which is a drop down list from my jsp what should i do and what is the process please give a brief view
How to get data from DB in to Text box by using Jsp & Ajax
How to get data from DB in to Text box by using Jsp & Ajax   I want to get the data from database in to text box in a jsp page by using Ajax. If I... with a and from that i need to select the required value and i should store
Retrieving data from data base using jsp combo box
Retrieving data from data base using jsp combo box  Hi guys please... combo box is there and another filed is version of the server(like 1.0,2.0) like... of the server it has to display the process name from database into the process name
Multiple buttons in struts using java script
Multiple buttons in struts using java script  Multiple buttons in struts using java script
How to remove virtual keypad from apps java
How to remove virtual keypad from apps java  I have an galaxy smart s6830 touch Chinese Mobile (240x320) (myriad java platform) (esmertec jbed) and I need to remove keypad from apps . I have put the following into the jar file
How to remove virtual keypad from apps java
How to remove virtual keypad from apps java  I have an galaxy smart s6830 touch Chinese Mobile (240x320) (myriad java platform) (esmertec jbed) and I need to remove keypad from apps . I have put the following into the jar file
How to remove virtual keypad from apps java
How to remove virtual keypad from apps java  I have an galaxy smart s6830 touch Chinese Mobile (240x320) (myriad java platform) (esmertec jbed) and I need to remove keypad from apps . I have put the following into the jar file
Acees data from database using combo box - JSP-Servlet
Acees data from database using combo box  please let me how i access the data from database when i select combo box combo2 having values Arts, Commerce, Science. this combo box will appear when first combo box class_name having
Dynamic loading of Combo box list using servlet - JSP-Servlet
Dynamic loading of Combo box list using servlet  I have the category... I give theortical descrption read it! Select a value from drop dwon box... * from Combolist"); List ulist = new ArrayList(); List clist = new ArrayList
Adding checkbox to List as item
Adding checkbox to List as item   can we add checkox to List  ...(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JList list = new... mouseClicked(MouseEvent event){ JList list = (JList) event.getSource
3 dropdown list from the database using JSP
3 dropdown list from the database using JSP  Hi, I'm new to JSP I want to create 3 dropdown list each depend on the other and get the options from the database using JSP
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 ... through combo box than other combobox show item price only select item name... how i... stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("Select * from item
Combo Box operation in Java Swing
, remove items from the combo box. This program shows a text field, a combo box... at the 0th (zero) position of the combo box will be remove from the combo box... for the position number of he of the item in combo box to remove it. Here is the code
retrieving from oracle database using jsp combo box
retrieving from oracle database using jsp combo box  hi this is my... name of the server has to display in the process name field from the oracle database please help on this i need code using servlets please help me . <
how to display data from mysql table in text box using jsp??
how to display data from mysql table in text box using jsp??  <p>hi, i have a written a code to display data from a mysql table into txtboxes... QueryString = "SELECT * FROM code<em>ot WHERE code</em>codeot=12
Hit Counter Schema using java script - WebSevices
Hit Counter Schema using java script   Dear Sir, I am sending you... page visits per unique session. Since visitor IP can be randomly assigned IP from... the cookie by using a random sessionID. for that I have to use a page
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
Add/Remove Rows Dynamically with drop down list in html table using php
Add/Remove Rows Dynamically with drop down list in html table using php  Here Is My Code. I want to give and get the id of drop down list. Can Anyone... the following link: JSP Add Remove row using Javascript
awt list item* - Swing AWT
awt list item*  how do i make an item inside my listitem... frame=new Frame("Add list"); Label label=new Label("What is your Choice...); choice.add("Java "); choice.add("Jsp"); choice.add("Servlets
Need to remove duplicate rows from the Excel Sheet using the Apache POI API
Need to remove duplicate rows from the Excel Sheet using the Apache POI API   Hi There, Is any one aware of java code on how to find the duplicate rows in excel.I am using the Apache POI API to achieve the same have googled
Java Remove a character from string
Java Remove a character from string In this tutorial, you will learn how to remove a character from the string. There are several methods for examining... to remove a particular character from the string. In the given example, we have
remove a substring from a string
remove a substring from a string  Please I jave an arraylist composed as follwoing [w1, w2, w3, w4, w1.w2.w3, w2.w3.w4, w3.w4, w2.w4, w1.w3, w1.w2] w2.w4 is a subset of w2.w3.w4 ?how I recognize it also ADS_TO_REPLACE_1 w1.w3
remove element from stack
remove element from stack  Hi there I'm looking around on the internet how to remove names from stack by asking user how many names they want... error message and if not then remove the names from stack until the stack is empty
PHP list box mysql
PHP List box that displays the data from mysql table. User can select any value from the PHP list box. Example of PHP MYSQL List Box Code <..._db($database, $chandle) or die ("Database not found."); $query1="select * from
How to access Contacts from gmail using LDAP in JSP dropdown list
How to access Contacts from gmail using LDAP in JSP dropdown list  HI, I am creating a JSP page in which i have to make a dropdown box, and access gmail contacts in that drop downlist using LDAP. Can any one plz help me out
dynamic drop down list box - Java Beginners
dynamic drop down list box  hi all , I want to dynamically populate a drop down box from an sql query in a servlet program, using only html...(); ResultSet rs = st.executeQuery("select * from Combolist"); List ulist = new
how to execute a unix shell script from a java program
how to execute a unix shell script from a java program  well , i am... the script name from a java code .once you execute this java program ultimately your script gets executed.. it would be a lot of help to me
navigation between panels when item is selected from jcombobox - Swing AWT
(2nd panel).the combo box is in main panel. when a item is selected from combobox the 2nd panel should navigate to other panel. for now i have 4 item in the combo...navigation between panels when item is selected from jcombobox  hi

Ads