I have two textareas, one on top of another, and I want to have a click of a button swap which one is viewed.
Here is the code I have so far:
<div id="textAreas">
<div style="position: relative" class = "container_row">
<div id="layer1" class="layer1">
<textarea style="top:0; left:0; z-index: 2" readonly id="editTextArea1" rows = "1" cols="40"> Layer 1 </textarea>
</div>
<div id="layer2" class="layer2">
<textarea style="top:0; left:0; z-index: 1; display: none" id="editTextArea2" rows = "1" cols = "40"> Layer 2 </textarea>
</div>
</div>
</div>
I then have a button:
<input type="image" onclick="switchButtons()" src="<c:url value="/resources/images/edit.png" />" name="edit" class="btTxt submit" id="saveForm" />
With the click of that button, the "layer2" textarea should be visible, and "layer1" textarea should not.
Here is the switchButtons() method in javascript:
function switchButtons() {
document.getElementById("layer1").style.display = "none";
document.getElementById("layer2").style.display = "block";
}
My goal is to have the layer1 textarea be visible, and readonly, and with the click of the button, have layer2 textare show up where layer1 textarea was, but be editable. Let me know what I can do. Thank you!