I am trying to use a form so that the user can select multiple towns as variables. The form than sends the variables to another script for processing.
I am not able to get it to work proberlem. It seems like the variables never get passed to the script.
Sometimes all you need is another pair of fresh eyes to find the problem.
Can someone please take a look at this code and offer a suggestion?
Thanks
<html>
<head>
<title></title>
<script language="Javascript">
<!--
function ClearList(OptionList, TitleName)
{ OptionList.length = 0;
}
function move(side)
{ var temp1 = new Array();
var temp2 = new Array();
var current1 = 0;
var current2 = 0;
var attribute;
//assign what select attribute treat as attribute1 and attribute2
if (side == "right")
{ attribute1 = document.rep.selecttown;
attribute2 = document.rep.selecttownselect;
}
else
{ attribute1 = document.rep.selecttownselect;
attribute2 = document.rep.selecttown;
}
//fill an array with old values
for (var i = 0; i < attribute2.length; i++)
{ temp1[current1++] = attribute2.options[i].value;
}
//assign new values to arrays
for (var i = 0; i < attribute1.length; i++)
{ if ( attribute1.options[i].selected )
{ temp1[current1++] = attribute1.options[i].value;
}
else
{ temp2[current2++] = attribute1.options[i].value;
}
}
//generating new options
for (var i = 0; i < temp1.length; i++)
{
attribute2.options[i] = new Option();
attribute2.options[i].value = temp1[i];
attribute2.options[i].text = temp1[i];
}
//generating new options
ClearList(attribute1,attribute1);
if (temp2.length>0)
{
for (var i = 0; i < temp2.length; i++)
{ attribute1.options[i] = new Option();
attribute1.options[i].value = temp2[i];
attribute1.options[i].text = temp2[i];
}
}
}
//-->
</script>
</head>
<body>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%">
<form action="newcode.php" method="POST" name ="rep">
<div align="center">
<center>
<table cellspacing="1" width="100%" height="123">
<tr>
<td bgcolor="#003366" align="center" colspan="3" width="270" height="18">
<strong><font face="Tahoma" color="#ffffff" size="2">Select a Town</font></strong>
</td>
<td bgcolor="#003366" align="center" width="240" height="18">
<strong><font face="Tahoma" color="#ffffff" size="2">Price Range</font></strong>
</td>
<td bgcolor="#003366" align="center" width="92" height="18">
<strong><font face="Tahoma" color="#ffffff" size="2">Bed Rooms</font></strong>
</td>
<td bgcolor="#003366" align="center" width="99" height="18">
<strong><font face="Tahoma" color="#ffffff" size="2">Baths Rooms</font></strong>
</td>
</tr>
<tr>
<td valign="top" height="97">
<p style="word-spacing: 0; margin-top: 0; margin-bottom: 0">
<select name="selecttown" multiple size="5" width="150px">
<option value="Lyme NH">Lyme, NH</option>
<option value="Hanover NH">Hanover, NH</option>
<option value="Lebanon NH">Lebanon, NH</option>
<option value="Plainfield NH">Plainfield, NH</option>
<option value="Enfield NH">Enfield, NH</option>
<option value="Canaan NH">Canaan, NH</option>
<option value="Grafton NH">Grafton, NH</option>
<option value="Grantham NH">Grantham, NH</option>
<option value="Eastman NH">Eastman, NH</option>
<option value="Orford NH">Orford, NH</option>
<option value="Piermont NH">Piermont, NH</option>
<option value="Haverhill NH">Haverhill, NH</option>
<option value="Bradford NH">Bradford, NH</option>
<option value="Chelsea VT">Chelsea, VT</option>
<option value="Corinth NH">Corinth, NH</option>
<option value="Strafford NH">Strafford, NH</option>
<option value="S. Strafford NH">S. Strafford, NH</option>
<option value="Thetford VT">Thetford, VT</option>
<option value="Norwich VT">Norwich, VT</option>
<option value="Hartford VT">Hartford, VT</option>
<option value="Wilder VT">Wilder, VT</option>
<option value="Quechee VT">Quechee, VT</option>
<option value="Hartland VT">Hartland, VT</option>
<option value="Woodstock VT">Woodstock, VT</option>
<option value="Barnard VT">Barnard, VT</option>
<option value="Pomfret VT">Pomfret, VT</option>
<option value="Cornish NH">Cornish, NH</option>
<option value="Sunapee NH">Sunapee, NH</option>
<option value="Newbury NH">Newbury, NH</option>
<option value="Sutton NH">Sutton, NH</option>
<option value="Barnard NH">Barnard, NH</option>
<option value="Bethel NH">Bethel, NH</option>
<option value="">----Secondary Towns----</option>
<option value="Ascutney VT">Ascutney, VT</option>
<option value="Barnard VT">Barnard, VT</option>
<option value="Bethel NH">Bethel, NH</option>
<option value="Brownsville VT">Brownsville, VT</option>
<option value="Chelsea NH">Chelsea, NH</option>
<option value="Croydon NH">Croydon, NH</option>
<option value="Windsor VT">Windsor, VT</option>
<option value="Fairlee VT">Fairlee, VT</option>
<option value="Dorechester VT">Dorchester, VT</option>
<option value="Randolph VT">Randolph, VT</option>
<option value="Sharon NH">Sharon, NH</option>
<option value="Springfield NH">Springfield, NH</option>
<option value="Vershire VT">Vershire, VT</option>
<option value="Windsor VT">Windsor, VT</option>
<option value="New London NH">New London, NH</option>
</select></p>
<p style="word-spacing: 0; margin-top: 0; margin-bottom: 0" align="center">
<input type="button" value="Add" onclick="move('right')"></p>
</td>
<td valign="top" height="97">
</td>
<td valign="top" height="97">
<p style="word-spacing: 0; margin-top: 0; margin-bottom: 0">
<select name="selecttownselect" multiple size="5" style="width=150px" width="150px">
</select></p>
<p align="center" style="word-spacing: 0; margin-top: 0; margin-bottom: 0"><input type="button" value="Remove"
onclick="move('left')">
</p>
</td>
<td valign="top" height="97">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="147">Enter your lowest price:</td>
<td>$<input value="0" name="lowprice" size="9"></td>
</tr>
<tr>
<td width="147">Enter your highest price:</td>
<td>$<input value="300000" name="highprice" size="9"></td>
</tr>
</table>
</td>
<td valign="top" height="97">
<input type="radio" CHECKED value="%" name="bedroomsel"><font face="Courier">Any<br>
<input type="radio" value="1" name="bedroomsel" ?>1<br>
<input type="radio" value="2" name="bedroomsel" ?>2<br>
<input type="radio" value="3" name="bedroomsel" ?>3</font>
</td>
<td valign="top" height="97">
<input type="radio" CHECKED value="%" name="bathselect"><font face="Courier">Any<br>
<input type="radio" value="1" name="bathselect">1<br>
<input type="radio" value="2" name="bathselect">2</font>
</td>
</tr>
<tr>
<td valign="top" colspan="6">
<p align="center"><input type="submit" value="Submit" name="B1">
</td>
</tr>
</table>
</center>
</div>
</form>
</td>
</tr>
</table>
</body>
</html>