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

document.myform.code + name ???

Hopefully this is an easy question for some of you... I am new to JS.

I have a document with a lot of different select menus with names like
code1, code2, code3... etc
I have a function that does some autoselecting based on your current
selection....

function selectFromCode(name) {

give the above as the constructor... how do I get the following to work???
var codename = "document.myform.code" + name;

For example, I want codename to be a reference to document.myform.code3 if I
call the function using selectFromCode("3") or selectFromCode(3)

But I cannot get this to work...

Help is greatly appreciated.
Jul 23 '05 #1
3 1189
On Thu, 18 Nov 2004 11:41:43 -0800, Sean Berry <se**@buildingonline.com>
wrote:

[snip]
var codename = "document.myform.code" + name;


[snip]

See <URL:http://www.jibbering.com/faq/faq_notes/square_brackets.html> and
<URL:http://www.jibbering.com/faq/faq_notes/form_access.html>.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #2
> [snip]
var codename = "document.myform.code" + name;


[snip]

See <URL:http://www.jibbering.com/faq/faq_notes/square_brackets.html> and
<URL:http://www.jibbering.com/faq/faq_notes/form_access.html>.


Thanks for the links Mike... very informative....

var codename = document.myform["code" + name];

Works like a charm

Jul 23 '05 #3
Sean Berry wrote:
Hopefully this is an easy question for some of you... I am new to JS.

I have a document with a lot of different select menus with names like
code1, code2, code3... etc
I have a function that does some autoselecting based on your current
selection....

function selectFromCode(name) {

give the above as the constructor... how do I get the following to work???
var codename = "document.myform.code" + name;


document.forms['formName'].elements['elementName' + somethingElse];

<url: http://jibbering.com/faq/#FAQ4_25 />
<url: http://jibbering.com/faq/#FAQ4_39 />

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq

Jul 23 '05 #4

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

Similar topics

3
by: F | last post by:
It seems that document.cookie doesn't work both on Internet Explorer 5 for Mac (OS 9) and Opera 6 for PC... am I doing something wrong? Or does it just not work? I don't get an error message, the...
13
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
2
by: johkar | last post by:
I am getting an Access denied error when I write to a new window. The situation and code are outlined below. I am setting the domain in the main window. The problem is that the window I am...
4
by: JV | last post by:
I thought I once saw somewhere that a global variable, "xyz" for example, could be declared and used so that instead of using "document.formname.elementname.value" one could use...
6
by: therig | last post by:
I'm having issues, I've spent many hours searching and I'm a noob at javascript, any help will be greatly appreciated. I keep getting the following error: Error: document.forms.sec11_A has no...
2
by: ThePope78705 | last post by:
Hi all, I have a very simple HTML page that coontains a form and some various text and hidden fields. When the page loads I want to read in the query string and update some of the text fields with...
23
by: Stanimir Stamenkov | last post by:
<form name="myForm" action="..."> <p><input type="text" name="myElem"></p> </form> As far as I was able to get the following is the standard way of accessing HTML form elements: ...
2
by: ChrisLA | last post by:
Hi; I've seen lots of discussion & disagreement on this issue, so any good explanation would be appreciated. Some people seem to think that "document.GetElementByID("MyName").submit(); should...
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?
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...
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
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
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...
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.