My questions is: how can this be rewritten so it will enable/disable other textfields associated with other dropdown menus? (as if we have the same code, but the select name "D2", "D3"…etc. and text field to enable associated with that select: "otherz2", "otherz3".
Start by validating your code. It will not pass. Among other things, you use uppercase letters in attribute names, such as onChange, which is valid HTML but invalid XHTML. Then you close your input tags with /> which is valid XHTML and invalid HTML.
I changed a few of the name attributes when I rebuilt this, so you’ll have to adjust the code.