473,385 Members | 1,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Function that allows me to create new dropdowns from previous dropdown

Hello all,

I'm fairly new to javascript, and this is what I'm looking for:

I'm pulling information from a database to a dropdown menu and I need to create a function so that when an item is selected, a new dropdown appears with the same dropdown minus whatever item was selected, I would like for this process to continue infinitely until a drop down is no longer selected. Any examples/ ideas are greatly appreciated.

Thanks!
Oct 24 '08 #1
5 999
Based on what you said, it sounds like you need to look into "cloneNode" and "removeChild". This is a neat article about dynamically copying form fields on your site with javascript:)

QuirksMode domform
Oct 25 '08 #2
Thanks, this is definitely what I was looking for and certainly puts me on the right track. I am having a difficult time getting the code for this example to execute as it does on the page, do you see anything at all wrong with the code he is using as an example? Or am I doing something wrong? I am also struggling to understand exactly where and how the function moreFields is called within the html.
Oct 27 '08 #3
Ok, so I got the form to do what I hoped, which is create an infinite number of dropdowns with an input box next to each selection for entering a $ amount. Now, my final question is: Is there a way to sum the values entered into these boxes?

Help is again appreciated!

Thanks!
Oct 27 '08 #4
when you submit you could call a function to do it....e.g.:

Expand|Select|Wrap|Line Numbers
  1. function submitMyForm(form){
  2.    var concat;
  3.    var i;
  4.    for(i in form.elements){
  5.       if(form.elements[i].value){
  6.         concat+=parseFloat(form.elements[i].value)
  7.       }
  8.    } 
  9.    return concat
  10. }
Oct 28 '08 #5
gits
5,390 Expert Mod 4TB
hi ... just a note ... i wouldn't use a variable name that is a reserved word for a native js-method that is implemented for strings/arrays ... even when it would work while its used in this local scope here in the shown function ... but its just a rule of thumb to avoid such reserved names for variables in your code ... it could be really hard to debug in case you don't handle that with great care and something ever goes wrong later on ... so just avoiding that just avoids this potential errors that will drive you crazy when they occur - i promise that ;) ... i made a review some weeks ago because of a strange behaviour of an app - i took us 3h to find out that it was the variable named with a JS-keyword that made this problem ...

as i said ... its just a hint to avoid a potential problem ;)

kind regards
Oct 29 '08 #6

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

Similar topics

3
by: Ron | last post by:
Hello, I am trying to create a C# test dll to try out in an MS Access mdb application. I open up a session of vs2003, select C#/Class Library. Here is my code: ...
3
by: Damon | last post by:
I am working on a site in which I would like to have two dropdowns that will allow a user to navigate through the administrative pages of the site. The first would allow the user to choose the...
3
by: Jon | last post by:
I am using cascading dropdowns, where one dropdown determines the data in the next, etc... If a dropdown has only one item in it, the SelectedIndexChanged event is never fired, even if you click...
1
by: Hifni Shahzard | last post by:
Hi, I'm using VS.NET 2003, SQL Server 2000, Windows xp professional; My Question: Some of you might seen in some websites where it requests the Country in a dropdown. If the Country selected,...
1
by: Andy | last post by:
What I want to do is to populate multiple dropdowns when editing. Presumably... a) I should use a DataReader so that I can get each ResultSet for each dropdown control, and that should cut down...
1
by: Paul D. Fox | last post by:
I'd like to populate four dropdowns using code behind. Each dropdown contains the same list. How can I populate them using a subroutine. Something like: InitializeDropDownList(ddlQuadrant1)...
6
by: daveyand | last post by:
Hey Guys, I've stumped. I created a function that does various things to select boxes. Namely Get All selected indexes, populate array with these values
7
by: Vik Rubenfeld | last post by:
I'm a Javascript newbie, but I do have some Javascript working. Here's the code I have on my html page to load javascript: ----- <script src="http://localhost:8888/js/jquery.js"...
0
by: sbart | last post by:
I am programing in asp.net vb using AjaxToolkit cascadingDropDown. I do not have access to AjaxToolkit cascading dropdown event handlers. I have a series of dropdowns. The selection from one of...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.