[SOLVED]Dropdown and prices

coppo82 25 Jun, 2013
Hi all i'm back with another question.

i have 2 dropdown and a formatted text form, what i need is this

dropdown1

banner1
banner2
banner3

dropdown2
month
6 month
1 year

what i need is to display a price for each combination of the 2 dropdown forms.

EX. banner1 + month = 10€
banner1 + 6month =50 €
banner1 + 1 year = 100 €

and so on also for the other banners

can please someone paste an example code ???

thanks a lot

Andrea
GreyHead 25 Jun, 2013
Hi Andrea,

You can do this with a dozen or so lines of custom JavaScript. You'll find quite a few examples in the forums here.

Bob
coppo82 25 Jun, 2013
Hi Bob,

i had look on the forum but i didn't found a right example,maybe i'm searching wrong.

i'm took a look also in the faq but also no result for what i need ..

if you have an example please post here .

thanks.

Andrea.
GreyHead 25 Jun, 2013
Hi Andrea,

There's a simple example here. Yours will need to be more complicated to handle the tow drop-downs and the range of values.

Bob
coppo82 25 Jun, 2013
ok i found i code that work fine for me

window.addEvent('domready', function() {
  $('banner_size').addEvent('change', rekenen1);
  $('abbo').addEvent('change', rekenen1);
  $('input_text_14').disabled = true; 
});
function rekenen1(){
  $('input_text_14').value = $('banner_size').value * 1 * $('abbo').value + ' €';
}


i just have a little problem . the dropdown called banner_size has 4 kind of banner.the problem is that 2 banner must have the same value

EX.

15=banner1
15=banner2
28=banner3
28=banner4

i need this value to calcolate with the code the final price .

how can i have 2 banner with the same value ?

thx
GreyHead 25 Jun, 2013
HI coppo82,

Look up the values from an array; or set the value to e.g. 28a and 28b and extract the numeric part.

Bob
coppo82 25 Jun, 2013
i will try to work with the " IF "
coppo82 25 Jun, 2013
ok i solved and it works fine .

i post here the solution if someone need it .


First
window.addEvent('domready', function() {
 $('banner_size').addEvent('change', function() { 
 if ($('banner_size').value == '120x600Px' ) { 
 $('input_text_14').value = '10'; 
 }
if ($('banner_size').value == '160x600Px' ) { 
 $('input_text_14').value = '15'; 
 }  
if ($('banner_size').value == '1000x150Px' ) { 
 $('input_text_14').value = '30'; 
 } 
if ($('banner_size').value == '500x75Px' ) { 
 $('input_text_14').value = '25'; 
 } 
});
 $('input_text_14').value = '0'; 
});


Second
window.addEvent('domready', function() {
 $('abbo').addEvent('change', function() { 
 if ($('abbo').value == 'Monatlich' ) { 
 $('input_text_19').value = '1'; 
 }
if ($('abbo').value == 'Halbjährlich' ) { 
 $('input_text_19').value = '6'; 
 }  
if ($('abbo').value == 'Jährlich' ) { 
 $('input_text_19').value = '12'; 
 } 
});
 $('input_text_19').value = '0'; 
});


3rd
window.addEvent('domready', function() {
  $('banner_size').addEvent('change', rekenen1);
  $('abbo').addEvent('change', rekenen1);
 $('input_text_20').readonly = true;   //readonly not work use disable 
 $('input_text_14').hide();
$('input_text_19').hide(); 
});
function rekenen1(){
  $('input_text_20').value = $('input_text_19').value * $('input_text_14').value + ' €';
}
GreyHead 25 Jun, 2013
Hi coppo82,

Well done :-)


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