473,474 Members | 1,850 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to removed selected options via Javascript?

1 New Member
I am new to javascript and this is all trial and error. When a user selects an option, the Id of teh option is added to a hidden form field, creating a list of id's. Each ID is displayed on the page. If you click the ID it should delete the id from the hidden form field and from view. The javascript below deletes the whole element. I have searched high and low but can not find anythning to help me remove the ID's when the user clicks the ID.

Expand|Select|Wrap|Line Numbers
  1. function deletef1_id(f1id){
  2.                             var x = document.forms[0].elements[f1id]; 
  3.                             x.parentNode.removeChild(x); 
  4.  
  5.                 }
  6.  
Expand|Select|Wrap|Line Numbers
  1. <div id="return_list_f1" style="background-color:cab4cd;padding:5px 0 5px;" name="return_list_f1">this is where the list of id's will appear as links</div>
  2.  
  3. <form action="test.cfm" method="post" name="feature" id="feature">
  4.                     <input type="hidden" name="f1_id" id="f1_id">
  5.                     <input type="hidden" name="f2_id" id="f2_id">
  6.                     <input type="submit" name="submit" value="submit">
  7.                 </form>
thanks to anyone who can help
Andrea
Jan 26 '11 #1
1 1413
JKing
1,206 Recognized Expert Top Contributor
Not sure if I completely understand your request or not but I'll give it a shot.

Try using the ID property of the element.
Expand|Select|Wrap|Line Numbers
  1. function deletef1_id(f1id){
  2.                             var x = document.forms[0].elements[f1id]; 
  3.                             x.id = ""; 
  4.                 }
  5.  
This will set the id of an element to an empty string.
Jan 26 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Kevin Lyons | last post by:
Hello, I am trying to get my select options (courses) passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html I am having difficulty getting the...
15
by: TJ Walls | last post by:
Hello All, Is it possible to create a <select> element with no selected options? I have tried setting the selectedIndex attribute to -1, but as far as I can tell this only works for <select...
5
by: bigfella | last post by:
Hello Folks, I would like a web page to have 2 menu lists The contents of the second menu list depending on the selection made in the first. The contents of the second would be populated...
2
by: Jim Corey | last post by:
A longer version of my problem is here: http://www.developersdex.com/asp/message.asp?p=1116&r=4327903 I have a large amount of javascript that I want to modify in my code (i.e. a routine called...
7
chunk1978
by: chunk1978 | last post by:
hello. so i have 2 select menus which add and remove options from a 3rd select menu... it seems, however, that it's not possible to use different select menus to toggle a 3rd, because when an...
16
by: vunet.us | last post by:
Hm... I used to have a function which drags some div element on mousemove. After I added: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://...
1
by: sathikbasha | last post by:
Can we set the margin of left,right and ect through Java Script
3
by: yurcheg | last post by:
Hi, I've searched the forum for this problem but haven't found anything relevant. I've got a javascript code which dynamically creates list-boxes in a form. It works perfectly fine in IE, but in...
9
by: Matthew Wells | last post by:
OK, I've narrowed down the problem. This works when in the aspx page <script type="text/javascript" > function btnFirst_Click() { alert("Hello");...
1
by: bobbly | last post by:
I am working on a Page that will reference data from a query. My query shows all of the companies I work with, about 1800 in total. I am creating a page where the user can select the customer from a...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.