dniwebdesign
09-27-2006, 06:35 AM
Alright, I have 1 form with multiple rows... (http://www.dni-server.no-ip.com/goals.php) for example and source of form.
Each row has a unique id (info is stored in a mysql database). However I want to update certain areas of the form using javascript (so the user can make sure the info is right, before submitting). The form elements are named according to row.
Average GAI PIM
1_average 1_gai 1_pim
8_average 8_gai 8_pim
and the numbers of the form inputs are decided via the database.
How can I update say the average for each row depending on each element of that row. (When I change 1_pim, it calculates the average and shows it on 1_average, and so on with 8_).
I figured I could use the below code to change it but no such luck...
<script language="javascript" type="text/javascript">
function calcStats(id) {
alert(document.stats.+id+_average.value);
}
</script>
and a form element would have:
<input type="text" size="5" name="1_pim" onchange="javascript:calcStats(1)">
The alert was just for testing to see if I could show the value of the 1_average.
Hope that made sense.... :confused:
Each row has a unique id (info is stored in a mysql database). However I want to update certain areas of the form using javascript (so the user can make sure the info is right, before submitting). The form elements are named according to row.
Average GAI PIM
1_average 1_gai 1_pim
8_average 8_gai 8_pim
and the numbers of the form inputs are decided via the database.
How can I update say the average for each row depending on each element of that row. (When I change 1_pim, it calculates the average and shows it on 1_average, and so on with 8_).
I figured I could use the below code to change it but no such luck...
<script language="javascript" type="text/javascript">
function calcStats(id) {
alert(document.stats.+id+_average.value);
}
</script>
and a form element would have:
<input type="text" size="5" name="1_pim" onchange="javascript:calcStats(1)">
The alert was just for testing to see if I could show the value of the 1_average.
Hope that made sense.... :confused: