How to multiply a value and use it dynamically in text

?
Guest 21 Aug, 2012
Hey there!

I have made a form which has some text boxes in it. In one of the boxes, a user can fill in a number of persons [VALUE] attending a summit. What I want to do next is have a checkbox underneath it saying "By pressing the submit button, I agree upon paying the fee of € [VALUE * 45,00] to bank account 123456789."

I know how to make such a checkbox, no problems so far. What I do need to figure out is how the [VALUE] is being multiplied by "45" and how I manage to dynamically post it in the text/label of the checkbox.

Can anyone help me out with this please?

Regards,
Frank
GreyHead 22 Aug, 2012
Hi Frank,

In the checkbox label - or in a Custom Element element if the checkbox label doesn't work add
By pressing the submit button, I agree upon paying the fee of €<span id='amount'></span> to bank account 123456789.

Then add this into a Load JS action in the ON Load event:
window.addEvent('domready', function() {
  $('VALUE').addEvent('keyup', function(){
    if ( $('VALUE').value > 0 ) {
      $('amount').set('text', $('VALUE').value * 45 );
    }
  });
});
You need to make sure that the VALUE element has it's ID set to VALUE for this to work.

Bob
This topic is locked and no more replies can be posted.