Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] Accessing form name
- From: schalk at volume4.com (Schalk)
- Subject: [Javascript] Accessing form name
- Date: Mon Nov 21 06:59:45 2005
diego nunes wrote:
>On 21/11/05, Schalk <schalk@xxxxxxxxxxx> wrote:
>
>
>>What is the best way to obtain a form name if it is not possible to pass
>>it into the script as such: formFunction(this);
>>
>>
>
> You want the "name", having the instance of the form, or wanna get
>the instance, based onde the "name"?
>
> 1) instance named "formInstance":
> alert(formInstance.name);
>
> 2) form named "formanswer":
> alert(document.forms['formanswer']);
> or, better, if you have an unique ID:
> alert(document.getElementById('formanswer'));
>
> Amplexos.
>
>
Thanks Amplexos.
But here is my problem:
I want to create a simple generic reset function for forms within
Joomla. Now, I do not know beforehand what the form name or id is and
therefore wanted to determine this with JavaScript. Here is what I have
so far:
function resetForm() {
var theForm = document.getElementsByTagName('form');
var formName = theForm.name;
alert(formName);
document.formName.reset();
}
This does get the form but name is returned as undefined. Where am I
going wrong or is there a simpler/better way to do this? Thank you.
--
Kind Regards
Schalk Neethling
Web Developer.Designer.Programmer.President
Volume4.Business.Solution.Developers
- Follow-Ups:
- [Javascript] Accessing form name
- From: Roger Roelofs
- [Javascript] Accessing form name
- From: Nick Fitzsimons
- [Javascript] Accessing form name
- From: diego nunes
- [Javascript] Accessing form name
- References:
- [Javascript] Accessing form name
- From: Schalk
- [Javascript] Accessing form name
- From: diego nunes
- [Javascript] Accessing form name
- Prev by Date: [Javascript] Accessing form name
- Next by Date: [Javascript] Accessing form name
- Previous by thread: [Javascript] Accessing form name
- Next by thread: [Javascript] Accessing form name
- Index(es):