M
M
Mesuti2018-02-07 22:27:18
JavaScript
Mesuti, 2018-02-07 22:27:18

How to take data in select from option except value and display it in #id?

Hey!
There is an input.
I'm used to taking only value values ​​and then doing math with it.
Here is an example:
5a7b52fb34db7867008137.jpeg

html
<p>Сумма: <span id="info1"></span></p>

<select onchange="costCalculator()"  id="money">
  <option value="10">Rub</option>
  <option value="20">Usd</option>
  <option value="30">Eur</option>
</select>

<p>Валюта: <span id="info2"></span></p>

JavaScript
function costCalculator() {
    
var y = document.getElementById("money").value; 
info1.innerHTML = y
        
var x = document.getElementById("money").value;   
info2.innerHTML = x
        
}


But in this code, only the value value is taken.
As in the Currency line: display not value, but Rub or Usd or Eur
I can't find a solution.
Thanks to all who answered!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RomanPrivalov, 2018-02-07
@Mesuti

Codepen
If I understood correctly, you are interested in something similar?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question