5
I have the following javascript function:
var opts = document.getElementById('id_endereco'); //localiza select
var str = opts.options[opts.selectedIndex].innerText; //Pega text do option
I need to remove part of the content from select, 'str', this value is variable, but I have a fixed word in all options, the word 'Address: '. I need to remove this word including everything that comes before it.
I tried to:
var resultado_str = str.replace(0, str.indexOf("Endereço: ") + 1, "");
document.getElementById('endereco_correto').value = resultado_str;
But it didn’t work.
The point is I need to clear the words that come before the 'Address: ', and keep the rest.
– sNniffer
@sNniffer I understood your problem, updated the answer with the new solution.
– Maicon Carraro
Ball show, worked very well, thank you
– sNniffer