i cant belive this crap.. i fixed it! i must have deleted
var type = document.formName.elements['Salary_type'].value;
at function getMonths
oh well at least it works!!
here the full code in case anyone else finds it usefull.
NOTE: obvioulsy u need to include your datbase connection, mines included in the session class.
<?php
require_once("includes/usersession.phpm");
$objSession = new UserSession();
?>
<html>
<head>
<script type="text/javascript">
<!--
function getMonths(){
var type = document.formName.elements['Salary_type'].value;
switch(type)
{
case(type="Annual salary"):
<?php
//salary range drop down
$salary_range = "select * from \"salary_range\"";
$result = pg_query($salary_range);
?>
<?php $i = 0;
while ($salary_range_result = pg_fetch_array($result))
{
?>
document.forms['formName'].month.options[<?php echo $i;?>] = new Option('<?php echo $salary_range_result['range'];?>', '<?php echo $salary_range_result['range']; $i++?>');
<?php
}
?>
break
case(n="2"):
alert("You typed "+n);
break
case(n="3"):
alert("You typed "+n);
break
default:
alert("Wrong number");
break
}
}
-->
</script>
</head>
<body>
<form name="formName" method="post" action="">
<?php
//Salary type range drop down
$Salary_type = "select * from \"salary_type\"";
$result = pg_query($Salary_type);
if (pg_num_rows($result)==0)
{
echo "no Salary types setup";
}
else
{
?>
<select name="Salary_type" onchange="getMonths();" >
<?php while ($Salary_type_result = pg_fetch_array($result))
{
$rows++;
echo '<option value="' . $Salary_type_result['type'] . '">' . $Salary_type_result['type'] . '</option> ';
}
?> </select>
<?php
}
?>
<select name="month">
</select>
</form>
</body>
</html>