how do you reference the previous field in a form?

From: Date: Mon, 27 Nov 2000 20:32:27 +0000
Subject: how do you reference the previous field in a form?
Groups: php.general 
Request: Send a blank email to php-general+get-27448@lists.php.net to get a copy of this message
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

« previous php.general (#27448) next »