Can anyone help?
I want to alter the select name part of a variable declaration using a variable i.e.

var $selectname="selectname";

var $name=document.form1.$selectname.value;

This returns an error - object null

This works fine
var $name=document.form1.selectname.value;

The problem is with 50 different select names I need to declare the variable 50 times
Any Ideas on how I might change the following code so that the options in select2 get passed to the $text variable when the second button is clicked.

David Gale

<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
function test(str){
alert (str + " " + $text);
<form name="form1" method="post" action="" >
<select name="select1" id="select1">
<option value="Black">Black</option>
<option value="Blue">Blue</option>
<a href="javascript:;" onClick="test('test string 2')"><img src="addbutton.gif" width="24" height="24" border="0"></a>
<select name="select2" id="select2">
<option value="Red">Red</option>
<option value="White">White</option>
<a href="javascript:;" onClick="test('test string')"><img src="addbutton.gif" width="24" height="24" border="0"></a> </p>