So I have a text area with the id of textBox, and I have a paragraph with the id of pwbox. Like so
<p id="pwbox"></p>
<textarea align="center" style="visibility:hidden;" id="textBox" autofocus></textarea>
I'm trying to hide the visible one and transfer the content of it to the hidden one. Then delete the content of the one that I'm hiding by calling hideP() like so:
<script>
var pHidden="no";
function hideP()
{
if (pHidden=="no"){
document.getElementById("textBox").innerHTML = document.getElementById("pwbox").innerHTML.slice(0, -1);
document.getElementById("pwbox").innerHTML = " ";
document.getElementById("pwbox").style.visibility = "hidden";
document.getElementById("textBox").style.visibility = "visible";
pHidden = "yes";
} else {
document.getElementById("pwbox").innerHTML = document.getElementById("textBox").innerHTML += "|";
document.getElementById("textBox").innerHTML = " ";
document.getElementById("pwbox").style.visibility = "visible";
document.getElementById("textBox").style.visibility = "hidden";
pHidden = "no";
};
};
</script>
It will switch the visibility but it won't transfer the content correctly, anyone know where I messed up at?
I call the function with something like this:
<a href="javascript:void" onclick="hideP()">Swap</a>
also the slice
and +="|"
is a mock cursor and is supposed to be there.