473,394 Members | 1,696 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,394 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 989
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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
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...
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
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...

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.