Just a thought; not sure what you're trying to do, but in order for the field to originally display something without input, a value would need to be set.
I also have a textbox which indicates the total marks. As the admin keeps on entering marks for each question, it will get updated (total=marks+total).
I tried the below code may be because its an array element i am not able to add.
I hope my question is clear. Can any one tell me how to add array elements in javascript
i am trying to add the contents of winning_amount and display into a new textfield called total. I am getting error, object does not support
I'm very confused by your code (such as, I've never seen an element name that contains square brackets--I don't know that that's wrong, but I've never seen it), but I think the error you're getting refers to the line where you defined "frm" as an HTML element with the Id "final_result", but then your syntax seems to be trying to call a function within that element, getElementById. I don't see what you're trying to do. Have you looked into the HTML attribute innerHTML? You can have, say, a <DIV> or nearly any other closed element (one with a closing tag). and insert whatever you want as the content between the opening and closing tags by something like:
<script language="JavaScript">
function Calculate()
{
var sum=0;
for (i=0;i<document.form1.marks.length;i++) {
if(document.form1.marks[i].value=='')
document.form1.marks[i].value=0;
sum += parseInt(document.form1.marks[i].value);
}
document.getElementById("total").value = sum;
}
</script>
I tried the above code. It works fine only when the number of questions is more than 1. If it is only one question, then even on after i enter marks, the total textfield shows 0.