My code is to change the url of 'href'
every time the user changes the select.
I did once to change the 'src'
of an image, but when I used href
it just did not work!
<script language="javascript" type="text/javascript">
function edit_music()
{
if (document.getElementById(\'select1\').value == "0") {
document.preview1.style.visibility = "hidden";
document.getElementById(\'random1\').style.visibility = "visible";
} else {
var selected = document.getElementById(\'select1\').options[document.getElementById(\'select1\').selectedIndex].value;
document.preview1.style.visibility = "visible";
document.preview1.href = "vinhetas/"+selected;
document.getElementById(\'random1\').style.visibility = "hidden";
}
}
</script>
Html:
<select id='select1' name='vinhetas' onchange='edit_music()'>
<option value='$arquivos'>".$arquivos."</option>
</select>
<a href="" name="preview1" id="preview1">Pré-ouvir</a>
What am I doing wrong?