473,543 Members | 1,903 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Simple variable/string question

I have three drop down menus that when changed call a simple js
function, passing a value i.e.

<SELECT name="Team" onChange="chang e('national');" >

the function defined at the beginning is

function change(which) {
current = document.premFo rm.Team.selecte dIndex;
document.images .premShirt.src = "assets/shirts/"
+document.premF orm.Team[current].value + ".gif";
}

the var 'which' is being passed succesfully, but i can't work out how
to change

document.premFo rm.Team.selecte dIndex;

into

document.whichF orm.Team.select edIndex;

depending on what value the function receives. My 3 forms are called
premForm,nation alForm and worldForm

Apr 3 '06 #1
2 1161
charliefortune said on 04/04/2006 8:57 AM AEST:
I have three drop down menus that when changed call a simple js
function, passing a value i.e.

<SELECT name="Team" onChange="chang e('national');" >

the function defined at the beginning is

function change(which) {
current = document.premFo rm.Team.selecte dIndex;
pass a reference to the select to the function:

<SELECT name="Team" onChange="chang e(this, 'national');">

now the your function is:

function change(selectEl , which)
{
current = selectEl.select edIndex;

document.images .premShirt.src = "assets/shirts/"
+ document.premFo rm.Team[current].value + ".gif";
}

the var 'which' is being passed succesfully, but i can't work out how
to change

document.premFo rm.Team.selecte dIndex;

into

document.whichF orm.Team.select edIndex;
Presuming the name of the form is 'nationalForm', then:
document.forms[which + 'Form'].Team.selectedI ndex;
Read the FAQ section on accessing properties:

<URL:http://www.jibbering.c om/FAQ/#FAQ4_39>


depending on what value the function receives. My 3 forms are called
premForm,nation alForm and worldForm

--
Rob
Group FAQ: <URL:http://www.jibbering.c om/FAQ>
Apr 3 '06 #2
Thank you, I have it working now, but without the parameter you added
to my function, the selectE1. I didn't quite get that bit, but I
obviously have some reading to so, so thanks again.

Apr 4 '06 #3

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

Similar topics

1
1774
by: Scott | last post by:
The following is the XML I have to work with. Below is the question <Table0> <CaseID>102114</CaseID> <CaseNumber>1</CaseNumber> <DateOpened>2005-06-14T07:26:00.0000000-05:00</DateOpened> <OnCallPerson /> <CallType>Exposure</CallType> <ExposureReason>General</ExposureReason> <OtherExposureReason>Unintentional</OtherExposureReason>...
7
2639
by: NS Develop | last post by:
What's wrong with the following: void SomeClass::someMethod(void) { A *ptrA = NULL; ptrA = &A(); .... }
15
417
by: Alex | last post by:
could somebody tell me the difference between those two styles: function abc(var1, var2){ /* logic in here */ } and abc = function(var1, var2){ /* logic in here */ }; When / why would I use one over the other?
51
8216
by: Alan | last post by:
hi all, I want to define a constant length string, say 4 then in a function at some time, I want to set the string to a constant value, say a below is my code but it fails what is the correct code? many thx!
0
7543
by: Tal Sharfi | last post by:
Hi everyone I recently had the need for StringGrid object same as the one that Delphi has. An object that helps show lists of other objects in a simple grid. I searched the news groups and found none, so, I wrote one and decided to share it with you. It's a very simple one with few functions. I derived a DataGrid and added to it a...
2
3384
by: kaiser | last post by:
Hello I am trying to get the last lines value in a text file and display it on screen / read it into a variable. When I run the following code in a console I get the following error "Use of unassigned local variable "LastLine"
5
1019
by: Tim::.. | last post by:
How do I transfer the value of one variable in one sub to another variable in another sub??? Thanks
4
1512
by: Armand | last post by:
Hi Guys, I have a set of array that I would like to clear and empty out. Since I am using "Array" not "ArrayList", I have been struggling in finding the solution which is a simple prob for those who experience. (For some reason I have to implement Array not ArrayLists) Below are the simple following code: Dim Array() As String Dim...
4
2609
by: SM | last post by:
Hello, I have a simple question, but can't find the answer. I have a string that contains a path to a file I want to add another string to the end of that string So, if i have : path = document/disco/album/hello.doc i want it to become : document/disco/album/hello_large.xls
30
3476
by: galiorenye | last post by:
Hi, Given this code: A** ppA = new A*; A *pA = NULL; for(int i = 0; i < 10; ++i) { pA = ppA; //do something with pA
0
7411
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7354
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...
0
7594
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. ...
0
7746
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...
1
7354
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7693
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...
1
5282
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...
0
4898
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...
0
3394
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...

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.