Hello!
First of all, I'm a newbie with Java script.
My need which is :
[list]I have different tickets (10€ to 50€)[/list]
[list]I have created a form where customer can choose the numbers of tickets they want[/list]
[list]I want the total of the order showing if the customer click on a button, so that he could change is mind before complete the order.[/list]
I have created my form as foolowing :
[list]I have a drop down with value from 0 to 10 for each ticket (id=dd_value of the ticket)[/list]
[list]I have a button id=btn_calc (it's a regular button not a submit button)[/list]
[list]I have succed in showing the total of the amount in a text box adapting this FAQ[/list]
I have a text box id=name=total_bons. Here is the code in the load JS action:
It's working perfectly.
However, I would like the amount of the order not to be editable.
I guess I should use a custom element, but I couldn't find how.
I have try to replace the text box by a custom element id=name=total_bons and
I have also find that the faq is working with a hidden box (but not very friendly because I want the result to be shown).
I have also try to put the result in a variable $form->data['total_bons'] and use it in a custom element or a formatted text with {total_bons}, but it doesn't work.
Is anyone can give me a clue please?
Flo
First of all, I'm a newbie with Java script.
My need which is :
[list]I have different tickets (10€ to 50€)[/list]
[list]I have created a form where customer can choose the numbers of tickets they want[/list]
[list]I want the total of the order showing if the customer click on a button, so that he could change is mind before complete the order.[/list]
I have created my form as foolowing :
[list]I have a drop down with value from 0 to 10 for each ticket (id=dd_value of the ticket)[/list]
[list]I have a button id=btn_calc (it's a regular button not a submit button)[/list]
[list]I have succed in showing the total of the amount in a text box adapting this FAQ[/list]
I have a text box id=name=total_bons. Here is the code in the load JS action:
window.addEvent('domready', function() {
$('btn_calc').addEvent('click', function() {
var sum;
sum = $('dd_10').value*10+$('dd_15').value*15+$('dd_20').value*20+$('dd_30').value*30+$('dd_50').value*50+$('dd_75').value*75+$('dd_100').value*100+$('dd_150').value*150;
$('total_bons').value = sum;
});
});
It's working perfectly.
However, I would like the amount of the order not to be editable.
I guess I should use a custom element, but I couldn't find how.
I have try to replace the text box by a custom element id=name=total_bons and
$('total_bons').value = sum;
by $('total_bons').value = '<?php echo('+ sum +'); ?>';
I have also find that the faq is working with a hidden box (but not very friendly because I want the result to be shown).
I have also try to put the result in a variable $form->data['total_bons'] and use it in a custom element or a formatted text with {total_bons}, but it doesn't work.
Is anyone can give me a clue please?
Flo