My javascript skills are not the best, but I've been working on them lately and one thing I wanted to do was set attributes for html option tags. I posted the project on jfiddle to make it a little easier to see. You can see that here. I think I'm just one line of code off or something.
How would I remove the selected attribute from option 2 and create the selected attribute for option 1? In other words so that when I open 'another-popup', option 1 is selected instead of option 2.
I recommend you check out the jsFiddle link, but I posted the code on this question as well. The javascript for the update link:
function updateSelected(id, removeID, parentID) {
document.getElementById(parentID).style.display = 'none';
document.getElementById(id).setAttribute("selected","selected");
document.getElementById(removeID).removeAttribute("selected")
}
The html:
<a href="#box" rel="popup">Popup</a>
<div id="box" class="popup">
<a href="#another-box" rel="popup" onClick="updateSelected("1", "2", "box");">Another box</a>
</div>
<div id="another-box" class="popup">
<form>
<select>
<option id="1">option 1</option>
<option id="2" selected>option 2</option>
</select>
</form>
</div>
Thanks for the help