Schuyler Kuhl
asked on
Calculate a recurring payment and enter the number into a text field
Greetings,
On a credit card transaction form for donations I have a field for donation and a check box for "Break my donation into 12 payments".
So if this check box is checked I'd like to divide the donation by 12 and enter it into the totalcharge field. If it is not checked then the total amount they entered will go into the totalcharge field.
I have had some luck doing similar manipulation in the past with jquery but I am struggling a bit with this one.
Any suggestions will be greatly appreciated.
Thank you.
Sky
On a credit card transaction form for donations I have a field for donation and a check box for "Break my donation into 12 payments".
So if this check box is checked I'd like to divide the donation by 12 and enter it into the totalcharge field. If it is not checked then the total amount they entered will go into the totalcharge field.
I have had some luck doing similar manipulation in the past with jquery but I am struggling a bit with this one.
Any suggestions will be greatly appreciated.
Thank you.
Sky
can you put some of your code?
ASKER
I have a text field called "donationtotal" and a text field called "chargetotal" and a check box called submode.
If submode is checked I want to divide donationtotal by 12 and make the result chargetotal. if it is not checked then donationtotal is copied to chargetotal.
If submode is checked I want to divide donationtotal by 12 and make the result chargetotal. if it is not checked then donationtotal is copied to chargetotal.
just write simple js function on change for Tickbox
function Tick12() {
var temp
temp=donationtotal
if submode == true {
temp=donationtotal /12
}
chargetotal = temp
}
function Tick12() {
var temp
temp=donationtotal
if submode == true {
temp=donationtotal /12
}
chargetotal = temp
}
ASKER
yes, this is what I am trying to do.
ASKER
Sorry i really don't know my syntax properly.
This is what I was writing in jquery:
<script>
$(document).ready(function (){
$('input[name=submode]').c lick(funct ion(){
if($(this).is(':checked')) {
$('input[name=chargetotal] ').val()= $('input[name=donationtota l]').val() /12;
}
else{
$('input[name=chargetotal] ').val()= $('input[name=donationtota l]').val() ;
}
});
});
</script>
This is what I was writing in jquery:
<script>
$(document).ready(function
$('input[name=submode]').c
if($(this).is(':checked'))
$('input[name=chargetotal]
}
else{
$('input[name=chargetotal]
}
});
});
</script>
ASKER
Ok, This is my script in the head:
<script language="JavaScript" type="text/javascript">
<!--
function CalculateTotal() {
if document.donform.submode.v alue == true {
document.donform.chargetot al.value=d ocument.do nform.dona tiontotal. value /12
}
document.donform.chargetot al.value = document.donform.donationt otal.value
}
//-->
</script>
Then on the form field I have this:
<input name="donationtotal" type="text" size="15" onChange="CalculateTotal() " />
But nothing happens at all.
Thank you.
<script language="JavaScript" type="text/javascript">
<!--
function CalculateTotal() {
if document.donform.submode.v
document.donform.chargetot
}
document.donform.chargetot
}
//-->
</script>
Then on the form field I have this:
<input name="donationtotal" type="text" size="15" onChange="CalculateTotal()
But nothing happens at all.
Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.