Hi there, beginners question i think.
I have an asp page which is creating varying numbers of rows depending on the sql statement. Each row has 6 textfields going across. These text fields are named dynamically using a result pulled from the database. For example the first text field is defined:
< input id="<%response.write(rs("Stock_Code"))%>" >
The next field along in the row, so it has a different ID, I have defined in this way:
< input id="<%response.write(rs("Stock_Code"))%>_actual" >
And this continues along the row. So I want my javascript to change the values of the 5 fields after the first one is altered so I use this:
onChange="updateAverageCost(this.id)" on the first text field.
My problem is in the script how do i refer to the other text fields in that particular row? I have tried the following script and many other similar attempts but i cant manage it.
function updateAverageCost(fieldID) {
var average2 = fieldID + "_average";
var actual2 = fieldID + "_actual";
var averagecost = document.form1.average2.value;
var actualcost = document.form1.actual2.value;
document.write(actualcost);
Anyway thanks in advance,
Dan
I have an asp page which is creating varying numbers of rows depending on the sql statement. Each row has 6 textfields going across. These text fields are named dynamically using a result pulled from the database. For example the first text field is defined:
< input id="<%response.write(rs("Stock_Code"))%>" >
The next field along in the row, so it has a different ID, I have defined in this way:
< input id="<%response.write(rs("Stock_Code"))%>_actual" >
And this continues along the row. So I want my javascript to change the values of the 5 fields after the first one is altered so I use this:
onChange="updateAverageCost(this.id)" on the first text field.
My problem is in the script how do i refer to the other text fields in that particular row? I have tried the following script and many other similar attempts but i cant manage it.
function updateAverageCost(fieldID) {
var average2 = fieldID + "_average";
var actual2 = fieldID + "_actual";
var averagecost = document.form1.average2.value;
var actualcost = document.form1.actual2.value;
document.write(actualcost);
Anyway thanks in advance,
Dan