473,785 Members | 2,327 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I change contents of pulldown?

Hi

I need to clear the contents of a pulldown and then load new contents
into it. Is this possible in Javascript? If so how?

Thanks

Nick Steele
Jul 23 '05 #1
2 1294
ns*******@hotma il.com wrote:
Hi

I need to clear the contents of a pulldown and then load new contents
into it. Is this possible in Javascript? If so how?


Yes, it is, but in what format are the replacement items?
function clearMenu(menu, keepHeader){
menu.length=kee pHeader?1:0;
}

function replaceMenu(men u,array,keepHea der){
clearMenu(menu, keepHeader);
a=array.length;
for(i=0;i<a;i++ ){
menu.options[menu.length]=new Option(array[i],array[i]);
}
}
Consider a select menu named "foo"

<HTMLelement
onclick="replac eMenu(document. forms[0].foo,['select a number',1,2,3,4])">

Mick
Jul 23 '05 #2

<ns*******@hotm ail.com> wrote in message
news:i1******** *************** *********@4ax.c om...
Hi

I need to clear the contents of a pulldown and then load new contents
into it. Is this possible in Javascript? If so how?

Thanks

Nick Steele


Yes it's possible :o)

something like this you'r looking for ?
<script type="text/javascript">
newOpt = []; //array with new values
newOpt[0] = "newVal1"
newOpt[1] = "newVal2"
newOpt[2] = "newVal3"
newOpt[3] = "newVal4"
function changeOpt(){
opt = document.frm.wh ee.options
for(var i=0;i<newOpt.le ngth;i++){
opt[i]=new Option(newOpt[i],newOpt[i]);
}
for(i=i;i<opt.l ength;i++)
opt[i]=null
}
</script>

<form name="frm">
<select name="whee">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</form>

<a href="#" onclick="change Opt();return false">Newvalue </a>

Best Regards

Nick
Jul 23 '05 #3

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

Similar topics

3
2624
by: R.G. Vervoort | last post by:
I would like to select an option in a pulldown, select a record in a mysql database depending on the pulldown selection and then put the data from the record in the textfields. I can retrieve the pulldown value using javascript I can open the database and select the record using php how can i combine the 2 to within the onchange option of the pull down.
1
1775
by: cgplays.com | last post by:
Are there any good places to look for asp.net modules for select pulldowns? There is a select pulldown on a site i do partial development on http://www.computergroupplays.com/fb-pres4.asp that has a 2 dimensional select pulldown, where the third input box gets filled with the items that match what a user selects in the 2nd pulldown. I want to find a web control module, or perhaps a good tutorial , that can do this. Mucho thanks for any...
3
4196
by: Mark R | last post by:
I have one .asp page with a SELECT pulldown list on it and some INPUT fields. When SUBMIT is clicked the form data is submitted to that same page and validated. If INPUT fields are empty the asp code will insert a visual indicator (e.g. *) to convey that the field must be filled in. However, if the user has made a selection in the pulldown list and has left an INPUT field empty, when the form reappears after validation, the pulldown menu...
2
1625
by: Mike | last post by:
Hello, I'm looking for an example of doing a page with pulldown menus, where the user selects a choice from the first pulldown, then based on that input, another appears, then the user selects from that one, and based on that input, yet another appears, etc... Thanks, Mike
1
6633
by: cgplays.com | last post by:
I have a select-pulldown at http://computergroupplays.com/fb-pres2.asp that changes the 3rd pulldown (Dbase) depending on what the user enters in the 2nd (Wk). My associate wants the values inside the select box to retain their values after hitting the Go-Submit button when selecting the 3 choices- they want to see the values retained on the next page when you look at the form. Below is the include file used to generate the dynamic...
2
8994
by: Oskar Wild | last post by:
Hello, how do I code it to display a select (pulldown) box only if the user has selected a certain option in another pulldown box? <select name=country> <OPTION value="France" SELECTED>France <OPTION value="Spain">Spain <OPTION value="Portugal">Portugal </select>
5
4779
by: Glenn Mulno | last post by:
Hi, I am trying to create a report page for several teams. Each team runs the same reports but the reports use different values. For a while this was getting insane everytime I updated the queries I had to change them in many places. Then I started using server side includes to keep me from changing some items in multiple places. There is still some double (quadruple) updating going on though when I make
2
3043
by: Danny | last post by:
Hello I am trying to create a separate listbox and fill it with items based on what is in another field in a database. This field is bound to a field in the underlying database. But the data is changed from another list box that is a pulldown of the 3 items. This way they are forced to select one of the 3 items. So when the field updates based on the item chosen, why doesnt it cause the "on change event" to happen? The field has...
4
8819
by: Richard MSL | last post by:
I am making a combobox, where I add items to the combobox as they are required, as the user scrolls to the top or bottom of the list of items. It is a sorted combobox. Scrolling down works fine, but when they scroll up, the positioning gets confused. If the ComboBox contains record 60-79, and they pressed Up on 60, I trap the keypress and add records 40-59. I set the SelectedItem to 59, and the SelectedIndex to its index, and the textbox...
0
9491
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10357
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10163
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9959
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7510
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4063
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 we have to send another system
2
3668
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.