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

Dinamically call form fields

<script>
var arrcampi = new Array("nome", "cognome", "email", "telefono", "via",
"localita", "cap", "cosa", "dove", "stelle", "prezzomassimo",
"nrsingole", "nrdoppie", "nrtriple", "dalgiorno", "dalmese", "dalanno",
"algiorno", "almese", "alanno");

for (i=0;i<=(arrcampi.length-1);i++){
document.mh./*here*/arrcampi[i].value = "";
}
</script>

I would like to pass form fields name from an array and "reset them all".

It doesn't work.

Which is the prob?

Any help much appreciated.

Best regards.

--
Fabri
(Incredibile come si tenda a credere di piu` a Rossi. (cit.))
Jul 23 '05 #1
2 987
Fabri wrote:
<script>
var arrcampi = new Array("nome", "cognome", "email", "telefono", "via",
"localita", "cap", "cosa", "dove", "stelle", "prezzomassimo",
"nrsingole", "nrdoppie", "nrtriple", "dalgiorno", "dalmese", "dalanno",
"algiorno", "almese", "alanno");

for (i=0;i<=(arrcampi.length-1);i++){
document.mh./*here*/arrcampi[i].value = "";
}
</script>

I would like to pass form fields name from an array and "reset them all".

It doesn't work.

Which is the prob?


The problem is that you didn't read the group FAQ.

http://jibbering.com/faq/#FAQ4_39
document.forms['mh'].elements[arrcampi[i]].value = '';

but if you want to reset the entire form, why not just
document.forms['mh'].reset() ?

--
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 #2
Randy Webb wrote:
The problem is that you didn't read the group FAQ.

http://jibbering.com/faq/#FAQ4_39
document.forms['mh'].elements[arrcampi[i]].value = '';
Yes, I'm very sorry. Thank you very much :-(
but if you want to reset the entire form, why not just
document.forms['mh'].reset() ?


I have another question about it:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Documento senza titolo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<script>
function f(){

document.A.nome.value = "Fabri";
alert(document.A.nome.value);
document.A.reset();
alert(document.A.nome.value);
}
</script>

</head>
<body>
<form name="B">
<input type="text" name="nome" value="">
<input type="reset" value="Cancella">
</form>

<form name="A">
<input type="hidden" name="nome" value="">
</form>

<a href="#" onClick="f();">Go!</a>
</body>
</html>

This page doesn't work if the input is of type hidden.

Switching form name from A to B it works.

Why?

Regards.

--
Fabri
(Incredibile come si tenda a credere di piu` a Rossi. (cit.))
Jul 23 '05 #3

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

Similar topics

1
by: wolfing1 | last post by:
So the html looks like this: <%@ Language="VBScript" %> <%Option Explicit %> <html> <head>...</head> <body> <form name="myform"> <table> <% for x=1 to 10 response.write "<tr><td><input...
0
by: Development | last post by:
Hi Folks! Maybe some one can give me a hand with this problem: I'm building one asp.net page that reads data from the table and builds the table and the controls dinamically, I create a dataset...
3
by: josepm | last post by:
Hello, My doubt is arround webforms and its load programatically. I have a class derived from System.Web.UI.Page (clsWebForm), with their own properties and methods. Inside another webform I...
2
by: Fabio Cavassini | last post by:
I have this code that load HTML tags (no including <html> or <body>) into a DIV dinamically... after correctly retrieving the HTML, I assign it to my DIV Container ...
32
by: Mateo | last post by:
I have char *array and it is dinamically alocated.... When I pass it to other function, I need to determine size of this array.... Problem: sizeof operator does not work with dinamically alocated...
2
by: basetta | last post by:
Hi, I need to know how I can use some objects create dinamically in vb.net form. My code creates some buttons in my windows form, then I would like to manage their click events, but I don't know...
0
by: Chepre | last post by:
Hi, I've the following problem. I load an assembly dinamically through code, but I can't call the method GetCredentials correctly, it's allways null. Assembly assem =...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...

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.