Re: how do you reference the previous field in a form?
| From: | Folke Ashberg | Date: | Mon, 27 Nov 2000 20:56:05 +0000 |
| Subject: | Re: how do you reference the previous field in a form? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-27459@lists.php.net to get a copy of this message | ||
Hi!
First off all it's document.forms[0].elements[0] , also you can use
document.forms[0].pizza
document.forms[0].pizza.selectedIndex is the actually selected field which
you can store on a variable during function MyFunction(M1)
so the next time MyFunction is called you can access that variable.
document.forms[0].pizza.options[#].value
document.forms[0].pizza.options[#].text
are btw. the correct classes you can change
regards
Folke
--
Folke Ashberg
Stage Internet Services GmbH
Technical Development
folke@fanstage.de
folke@fanstage.de | Tel: +49 89 454591-77 | Fax: +49 89 454591-71
Kreillerstr. 21 | 81673 Munich | Germany | www.fanstage.de
On Mon, 27 Nov 2000, Ed Lazor wrote:
> This is a javascript question. I'm hoping I don't piss someone off by
> posting my question here, but this is the best place, because I'm sure
> someone here knows the answer (it's probably a simple question really).
>
> if I have a form field with an onChange parameter, like this:
>
> <input name=pizza>
> <select name=test onChange="MyFunction(this)">
>
> and then in the same document, I define the javascript function, like this:
>
> <script language="JavaScript1.2">
> function MyFunction(M1)
> {
> // hello world
> }
>
> How do I reference the value of the field one prior to the one calling the
> function? I know that I can do it manually like this:
>
> document.forms[0][elements[0]
>
> In order for my function to work properly, I need it to be more dynamic. I
> need it to know how to reference the previous field to change it's value.
>
> Thanks in advance =)
>
> -Ed
>
>
>