473,406 Members | 2,378 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,406 software developers and data experts.

Filling multiple drop boxes at once

Hi,

I made a page with two drop boxes in, with the aim of repeating a lot
of times. I set it up so that instead of repeating the options for
each box they would be filled in when the page was loaded. The two
boxes worked fine with that and a number of other functions they
performed but now I've come to duplicate them and I've hit a problem.

I have named each drop down box consecutively (sp?) and have a while
loop to fill them but its not working.

Please see the code below:

function load(){
var i = 0;
while (i <= 10) {
var selcat = ("category" + i);
var selpri = ("price" + i);
var selnam = ("name" + i);
document.order.selpri.value = "";
document.order.selcat[0] = new Option("Please select...", "cat",
true);
document.order.selcat[1] = new Option("Accessories", "acc", false);
document.order.selcat[2] = new Option("Bolted Silo", "bol", false);
document.order.selcat[3] = new Option("Welded Silo", "wel", false);
document.order.selcat[4] = new Option("Horizontal Silo", "hor",
false);
document.order.selnam[0] = new Option("Please select a category...",
"cat", false);
i++;
} }

Am I being really silly and missing something obvious? I tried using
getElementById but that didn't work, I'm thinking because technically
its not the id.

Any help would be much appreciated! Thanks

Mar 7 '07 #1
2 1350
On Mar 7, 10:53 am, "Flic" <Felici...@gmail.comwrote:
I made a page with two drop boxes in, with the aim of repeating a lot
of times. I set it up so that instead of repeating the options for
each box they would be filled in when the page was loaded. The two
boxes worked fine with that and a number of other functions they
performed but now I've come to duplicate them and I've hit a problem.

I have named each drop down box consecutively (sp?) and have a while
loop to fill them but its not working.
add method of select element -
http://msdn.microsoft.com/workshop/a...ethods/add.asp

--------untested-----
var selElement;
function load(){
var i = 0;
while (i <= 10) {
selElement=document.createElement("select")
addOption("text","value")
addOption("text","value")
document.body.appendChild(selElement)
i++
}
}

function addOption(t,v){
var oOption = document.createElement("OPTION");
selElement.options.add(oOption);
oOption.text=t; oOption.Value = v
}

Mar 7 '07 #2
On Mar 7, 5:34 pm, scripts.cont...@gmail.com wrote:
On Mar 7, 10:53 am, "Flic" <Felici...@gmail.comwrote:
I made a page with two drop boxes in, with the aim of repeating a lot
of times. I set it up so that instead of repeating the options for
each box they would be filled in when the page was loaded. The two
boxes worked fine with that and a number of other functions they
performed but now I've come to duplicate them and I've hit a problem.
I have named each drop down box consecutively (sp?) and have a while
loop to fill them but its not working.

add method of select element -http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/add...

--------untested-----
var selElement;
function load(){
var i = 0;
while (i <= 10) {
selElement=document.createElement("select")
addOption("text","value")
addOption("text","value")
document.body.appendChild(selElement)
i++

}
}

function addOption(t,v){
var oOption = document.createElement("OPTION");
selElement.options.add(oOption);
oOption.text=t; oOption.Value = v

}- Hide quoted text -

- Show quoted text -
The code I have works adding elements as I made it work for a single
one before expanding it. It just doesn't work in the loop, and thats
what I want help with.

Mar 7 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Tim | last post by:
Hello All! I'm having a difficult problem and I'm wondering if anyone can help. Here's the deal. I have a webpage with multiple forms on it. All of the forms have drop down boxes that when...
2
by: John Kreps | last post by:
(acc 2002) I've got six unbound text boxes on a subform that has a white background. Each of those six boxes has an expression that when true, will change its background from white to another...
1
by: Pax S | last post by:
I need a button that will check (make true) two check boxes (fields) For the record that has the focus (the record on the form that I am presently looking at). The two check boxes would be like a...
5
by: -elniniol999- | last post by:
I am DESPERATE for a quick reply.. have exhausted my options... i have a table called order details which contains: order id product id product name quantity unit price sale price
2
by: ramesh | last post by:
hi, I am using Com+ in my application. It will have InsertRecords,selectRecords,updateRecords function. In the Web Form i have Drop-down list. I want to select records from SQL and add it to this...
2
by: macyp | last post by:
I have to pass values from one aspx page to another. The controls I have in the first page are: a textbox, 3 drop down lists, and 2 check boxes, and a submit button. It is a search page, and the...
7
by: callawayglfr | last post by:
I am building a database in access where I have a drop down box that relates to a text box, that part I have working but when someone selects information from the first drop down I need it to limit...
10
by: 60325 | last post by:
This is the page where I collect the data in drop-down boxes with values of 1-10 and send it to a submitted page to do calculations. Example: Employee1 TeamScore(1-10) Employee2 ...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.