I have a span that works to display a currency symbol at the start of a price input box that changes based on what currency is selected in a dropdown box. These work by calling notEmpty() with an onChange event.
My code was:
function notEmpty(){
var e = document.getElementById("currencysel");
var strUser = e.options[e.selectedIndex].value;
var strUser2 = " " + strUser;
document.getElementById('currencysym').innerHTML = strUser2;
}
notEmpty()
document.getElementById("currencysel").onchange = notEmpty;
I had to add the to properly align the symbol in the price text box.
This worked perfectly until I made two changes, I no longer use the actual currency symbol (£, $, €) as the value because MySQL does not like the £ symbol, I now use GBP, USD and EUR. The second change is with each row, I load a form that includes both the currencysel dropdown and the currencysym span. Now fixing this is easy, I can just append the row ID to the end of the currencysel and currencysym IDs, so an example row may have currencysel6 and currencysym6, but how do I get the JavaScript to still recognize these despite the numbers on the end?
For the first issue, I tried:
function notEmpty(){
var e = document.getElementById('currencysel');
var strUser = e.options[e.selectedIndex].value;
if (strUser = 'GBP'){
strUser2 = ' £'
} else if (strUser = "USD"){
strUser2 = ' $'
} else if (strUser = "EUR"){
strUser2 = ' €'
}
document.getElementById('currencysym').innerHTML = strUser2;
}
But this didn't work.
The second issue I didn't have a single clue, which is where I'm hoping to receive your assistance.
Fiddle: http://jsfiddle.net/66co5kfo/
table?