Вот, вроде бы правильно, но не работает.
<div class="forms">
<form action="index.php" method="POST">
<h1>
<?php while($obj = mysql_fetch_assoc($res))
{
echo $obj['name'];
?></h1>
<select onchange="changePrice(this.value)">
<option><?php echo $obj['wk1']; ?></option>
<option><?php echo $obj['wk2']; ?></option>
<option><?php echo $obj['wk3']; ?></option>
<option><?php echo $obj['wk4']; ?></option>
</select>
<?php } ?>
<input type="text" name="time" value="time">
<br><br>
<h2><font color="maroon">Base services: </font></h2>
<?php
$data = array();
$id = 0;
$i=1;
while($row2 = mysql_fetch_assoc($res2))
{
$data[] = array('wk1' => $row2['price_wk1'],
'wk2' => $row2['price_wk2'],
'wk3' => $row2['price_wk3'],
'wk4' => $row2['price_wk4']);
?>
<tr><td>
<?php echo $row2['name']; ?>
</td>
<td id="price<?php echo $id; ?>"></td></tr><br/>
<?
$i++;
}
print_r($data);
?>
<script type="text/javascript">
prices = eval('{'+<?php echo json_encode($data); ?>+'}');
function changePrice(val)
{
for (i in prices)
{
document.getElementById('price'+i).innerHTML = prices[i][val];
}
}
</script>
Подскажите в чём ошибка