Here is my form and it still doesn't work. The form name doesn't have to be the name of the page I am on does it?
<form name="form1" method="POST" action="1.php">
<b>
<h2>Economic Indicators</h2>
</b>
<p align="left">Please select the regional unit of your interest: <br>
<select name="cboregion" size="6" multiple class="listbox" onClick="changeAction()">
<?php
/
Create your SQL statement
/
$sql="SELECT reg_id, reg_name from tbl_regions;";
$result_set = pg_Exec ($conn, $sql);
$rows = pg_NumRows($result_set);
if ((!$result_set) || ($rows < 1)) {
//No connection or no rows returned, so print an error
echo "<H1>ERROR - no rows returned</H1><P>";
exit; //exit the script
}
for ($j=0; $j < $rows; $j++) {
echo "<option value=".pg_result($result_set, $j, "reg_id")."> ".pg_result($result_set, $j, "reg_name")."</option>";
}
?>
</select>
<input type="submit" name="submit" value="submit">
<script language="JavaScript">
function changeAction()
{
//notice form1 again? This needs to be the same as the
//name attribute in your form tag
var formEle = document.form1;
//Make sure 'regions' is the same as the name attribute in
//your select tag
var selectEle = formEle.cboregion;
var regionVal = selectEle.options[selectEle.selectedIndex].value;
if ((regionVal == '4') {
formEle.action = '1.php';
}
else {
formEle.action = 'home2.php';
}
}
</script>
</FORM>