jwdcfdeveloper
Programmer
I am working on some javascript that assigns dynamic field names and values. I use the dynamic values to calculate a price, which works, but the price changes by the checked amount (except zero) whehever a user checks or unchecks the field. I want to be able to add the form field name with the checked attribute. Unfortunately, I don't know how to get and use the form field name.
I want to do something like this:
<script>
function total(cost, formfield) {
var total = cost.value;
var nameOfField = //someway to get convert formfield to the name of the form field
var current = document.frmName.totalCost.value;
if(total != 0 && document.frmName.nameOfField.checked) {
//add up totals
}
}
</script>
If anyone has a better way of doing this or knows how to pass and use the name of a dynamically generated name, I'd appreciate it.
I want to do something like this:
<script>
function total(cost, formfield) {
var total = cost.value;
var nameOfField = //someway to get convert formfield to the name of the form field
var current = document.frmName.totalCost.value;
if(total != 0 && document.frmName.nameOfField.checked) {
//add up totals
}
}
</script>
If anyone has a better way of doing this or knows how to pass and use the name of a dynamically generated name, I'd appreciate it.