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

elements of a form

hello,
i'm not very good with english
i will explain my problem wit an exemple:
// i have a form called dati
var nome_var="email"; //for exemple
ex1=document.dati.elements[nome_var].value //it's ok, work right
document.dati.email.focus( ) //it's ok, work
right
document.dati.elements['email'].focus( ) //it's ok, work right
//but i need something like this:
document.dati.elements[nome_var].focus //IT IS NOT OK

how can i get focus to "emial" element of form dati, using a variable unitl
the 'name'.

thank you for help.
Jul 23 '05 #1
6 1257
"kirku" <ki****@nospam.it> wrote in message
news:ek*********************@news3.tin.it...
hello,
i'm not very good with english
i will explain my problem wit an exemple:
// i have a form called dati
var nome_var="email"; //for exemple
ex1=document.dati.elements[nome_var].value //it's ok, work right
document.dati.email.focus( ) //it's ok, work
right
document.dati.elements['email'].focus( ) //it's ok, work right
//but i need something like this:
document.dati.elements[nome_var].focus //IT IS NOT OK

how can i get focus to "emial" element of form dati, using a variable unitl the 'name'.

thank you for help.

Try ".focus()".

Also, try "document.getElementById(nome_var).focus()".
Jul 23 '05 #2
Lee
kirku said:

hello,
i'm not very good with english
i will explain my problem wit an exemple:
// i have a form called dati
var nome_var="email"; //for exemple
ex1=document.dati.elements[nome_var].value //it's ok, work right
document.dati.email.focus( ) //it's ok, work
right
document.dati.elements['email'].focus( ) //it's ok, work right
//but i need something like this:
document.dati.elements[nome_var].focus //IT IS NOT OK

how can i get focus to "emial" element of form dati, using a variable unitl
the 'name'.


document.dati.elements[nome_var].focus();

Jul 23 '05 #3
On Sat, 30 Oct 2004 20:05:07 GMT, McKirahan <Ne**@McKirahan.com> wrote:

[snip]
Also, try "document.getElementById(nome_var).focus()".


Which won't work unless nome_var represents the id of the control.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #4

"Lee" <RE**************@cox.net> ha scritto nel messaggio
news:cm********@drn.newsguy.com...
kirku said:

hello,
i'm not very good with english
i will explain my problem wit an exemple:
// i have a form called dati
var nome_var="email"; //for exemple
ex1=document.dati.elements[nome_var].value //it's ok, work right
document.dati.email.focus( ) //it's ok, work
right
document.dati.elements['email'].focus( ) //it's ok, work right
//but i need something like this:
document.dati.elements[nome_var].focus //IT IS NOT OK

how can i get focus to "emial" element of form dati, using a variable unitlthe 'name'.


document.dati.elements[nome_var].focus();


it don't work, i forget the ( ) above in the exemple, but i used on script,
but it don't work!
Jul 23 '05 #5
kirku wrote:
"Lee" <RE**************@cox.net> ha scritto nel messaggio
news:cm********@drn.newsguy.com...
kirku said:
hello,
i'm not very good with english
i will explain my problem wit an exemple:
// i have a form called dati
var nome_var="email"; //for exemple
ex1=document.dati.elements[nome_var].value //it's ok, work right
document.dati.email.focus( ) //it's ok, work
right
document.dati.elements['email'].focus( ) //it's ok, work right
//but i need something like this:
document.dati.elements[nome_var].focus //IT IS NOT OK

how can i get focus to "emial" element of form dati, using a variable
unitl
the 'name'.


document.dati.elements[nome_var].focus();

it don't work, i forget the ( ) above in the exemple, but i used on script,
but it don't work!


Post the URL to a sample page that displays your problem.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
Jul 23 '05 #6
kirku <ki****@nospam.it> wrote:
"Lee" <RE**************@cox.net> ha scritto nel messaggio
news:cm********@drn.newsguy.com...
kirku said:
how can i get focus to "emial" element of form dati, using a variable
unitl the 'name'.

document.dati.elements[nome_var].focus();

it don't work, i forget the ( ) above in the exemple, but i used on script,
but it don't work!


pero una cosa cosi :

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- <!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN"> -->
<html lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>dov'e il focus ?</title>
</head>
<body>
<form name="dati">
email : <input type="text" name="email">
nome : <input type="text" name="nome">
cita : <input type="text" name="cita">
</form>
<script type="text/javascript">
var nome_var;
var valore_var;
nome_var = "nome";
valore_var = "alighieri";
document.dati.elements[nome_var].value = valore_var;
alert("primo passagio : " + nome_var + " : " + valore_var);
document.dati.elements[nome_var].select();
nome_var = "cita";
valore_var = "firenze";
document.dati.elements[nome_var].value = valore_var;
alert("secundo passagio : " + nome_var + " : " + valore_var);
document.dati.elements[nome_var].select();
nome_var = "email";
valore_var = "@inferno";
document.dati.elements[nome_var].value = valore_var;
alert("tertio passagio : " + nome_var + " : " + valore_var);
document.dati.elements[nome_var].focus();
</script>
</body>
</html>

--
@@@@@
E -00 comme on est very beaux dis !
' `) /
|\_ =="
Jul 23 '05 #7

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

Similar topics

5
by: Richard Cornford | last post by:
I am interested in hearing opinions on the semantic meaning of FORM (elements) in HTML. I have to start of apologising because this question arose in a context that is not applicable to the...
3
by: Perttu Pulkkinen | last post by:
What si the best and MOST BROWSERCOMPATIBLE way of making elements disabled for the user? Also considering different kind of elements: textfields, selects, radiobuttons and textareas. This is what...
1
by: Howard Jess | last post by:
Apparently, form elements of type <input type="image" src="...> are not included in the form's elements collection. I don't understand why not; according to DOM2, all form control elements...
12
by: Pudlik, Szymon | last post by:
Hi, I've written some code: function onSubmit(form){ for (var i = 0; i < form.elements.lenght; i++){ if (form.elements.disabled == 1) form.elements.disabled = 0; }
22
by: Luke | last post by:
Elements with name attribute: form, input, textarea, a, frame, iframe, button, select, map, meta, applet, object, param, img (if you know more reply...) Methods of addresing html elements:...
25
by: Dave | last post by:
Hello. In trying to get an anchor element to stylistically match an input or button element, I find that the button and input cannot be styled according to the 2.1 CSS spec. For example, I...
4
by: SteveKlett | last post by:
I have a subset of form items that I need to perform different operations on (enable/disable, clear values, change style, etc) rather than hard code the IDs or names I would like to recursively...
2
by: mars123 | last post by:
hi, I am facing a js error in my code, below is the prob. statement I have a radio2 javascript function as below, it works like this.. When a parent radio button is selected only one of its...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
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
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
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
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,...

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.