Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 7th, 2004, 06:14 PM
Authorized User
 
Join Date: Jun 2003
Location: Sheridan, OR, USA.
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to remove an option from a list

Hi:

I'm looking to allow users to remove items from a select list, but I'm not certain how to go about that in Javascript. I know how to append items to a select list, but not to remove.

I'm guessing that it will involve returning the options array from the select list, looping through it until the item to delete is found, skipping it, and then running through the remaining items, so that they all move up on position in the index. But that still would seem to leave one extra item (blank) at the end of the list.

This technique would probably be the same as inserting a new option in a select list, as opposed to simply appending to it.


Thanks for your time,

JK
Reply With Quote
  #2 (permalink)  
Old November 7th, 2004, 07:17 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: High Wycombe, UK, United Kingdom.
Posts: 344
Thanks: 0
Thanked 1 Time in 1 Post
Default

just set the value to null :

document.forms['testform'].testselect.options[i] = null;

see http://www.quirksmode.org/js/options.html
Reply With Quote
  #3 (permalink)  
Old November 7th, 2004, 09:45 PM
Authorized User
 
Join Date: Jun 2003
Location: Sheridan, OR, USA.
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Should've known. I keep looking for things like .addNew and .delete methods.

Thanks,
JK
Reply With Quote
  #4 (permalink)  
Old November 8th, 2004, 08:06 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: delhi, delhi, India.
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

John,
Do you want to delete the selectbox items by clicking the "Delete" button and Add New Items using "ADDNew" Button??


vinod
Reply With Quote
  #5 (permalink)  
Old November 8th, 2004, 08:14 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: delhi, delhi, India.
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

John ,
Hope this link help you
http://www.eddiesoft.com/eddiesoft/t...ls/entry2.html


vinod
Reply With Quote
  #6 (permalink)  
Old November 9th, 2004, 11:09 PM
Authorized User
 
Join Date: Jun 2003
Location: Sheridan, OR, USA.
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Vinod:

Thank you for the information, but Greg did answer my question. I may not have been clear enough when stating that in my response to Greg.

I really do appreciate your follow up.

Thanks,
JK
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create Check Boxes/Option buttons/Option Group hewstone999 Access VBA 1 March 14th, 2008 07:25 AM
Remove <select a value> option roy_mm Reporting Services 0 February 25th, 2007 02:26 AM
fill dropdown list with items when parent list isaac_cm Pro PHP 1 July 10th, 2006 05:41 AM
Remove value of dropdown list when textbox changed sn00pyg4rfi3ld Javascript How-To 1 January 20th, 2005 07:08 AM
Remove entries in a list box rfinks Classic ASP Basics 1 October 15th, 2003 12:48 PM



All times are GMT -4. The time now is 03:24 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.