Change content according to select option

Asked

Viewed 492 times

-1

Someone could assist me on how I can change the information that is in blue in the image below, according to the selection of the select (monthly, quarterly, semi-annual and annual).

I need you to change the product value and link button:

inserir a descrição da imagem aqui

The code I have is this:

<select class="select-ciclos" name="select" onchange="document.getElementById('selecionado').innerHTML = '' + this.value;">   
<option value="<sup>R$</sup><span>9,99</span>/mês" selected="selected">Mensal</option>
<option value="<sup>R$</sup><span>28,77</span>">Trimestral -4%</option>  
<option value="<sup>R$</sup><span>54,14</span>">Semestral -8%</option>
<option value="<sup>R$</sup><span>99,99</span>/ano">Anual -16%</option>  
                        </select>

 <div id="selecionado" class="price"><sup>R$</sup><span>9,99</span>/mês</div>

However, this way that I have, it stays only in one of the tables.

I would like to leave a single select outside the tables so that when selecting, change them all at once.

  • 1

    using innerHTML =)

  • Marcelo, I’m already using, but I want a help to separate a single select for all value fields.

  • It’s not working anymore?

  • Post your javascript

  • No js. Only onchange="Document.getElementById('selected'). innerHTML = '' + this.value;"

  • 4
Show 1 more comment

1 answer

0

First try to assign an id to each option, so it is easier to access them by javascript. Then assign Ids to the content as well (for example H1 id="meuh1") and leave this content hidden, then try something like this:

$"#optionID".select(function(){
  $"#meuh1".show();
  });

I hope it helps...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.