473,387 Members | 1,603 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,387 software developers and data experts.

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="change('national');">

the function defined at the beginning is

function change(which) {
current = document.premForm.Team.selectedIndex;
document.images.premShirt.src = "assets/shirts/"
+document.premForm.Team[current].value + ".gif";
}

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

document.premForm.Team.selectedIndex;

into

document.whichForm.Team.selectedIndex;

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

Apr 3 '06 #1
2 1160
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="change('national');">

the function defined at the beginning is

function change(which) {
current = document.premForm.Team.selectedIndex;
pass a reference to the select to the function:

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

now the your function is:

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

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

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

document.premForm.Team.selectedIndex;

into

document.whichForm.Team.selectedIndex;
Presuming the name of the form is 'nationalForm', then:
document.forms[which + 'Form'].Team.selectedIndex;
Read the FAQ section on accessing properties:

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


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

--
Rob
Group FAQ: <URL:http://www.jibbering.com/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
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>...
7
by: NS Develop | last post by:
What's wrong with the following: void SomeClass::someMethod(void) { A *ptrA = NULL; ptrA = &A(); .... }
15
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...
51
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...
0
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...
2
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...
5
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
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...
4
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 =...
30
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
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: 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:
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: 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
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
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...

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.