javascript: how to make input selected
- by Syom
i have to use the following function, to change the input's type
<input class="input" id="pas" type="text" name="password" style="color: #797272;"
value= "<?php if ($_POST[password] != '') {echo '';}
else {echo '????????';}?>"
onclick="if (this.value =='????????') {
this.value='';
this.style.color='black';
change();
}"
/>
<script type="text/javascript">
function change()
{
var input=document.getElementById('pas');
var input2= input.cloneNode(false);
input2.type='password';
input.parentNode.replaceChild(input2,input);
}
</script>
it works fine, but i have to reclick on input, because it creates a new input.
so what can i do, if i want it to create a new input with cursor in it?
thanks