javascript: how to make input selected
Posted
by Syom
on Stack Overflow
See other posts from Stack Overflow
or by Syom
Published on 2010-04-08T13:07:49Z
Indexed on
2010/04/08
13:13 UTC
Read the original article
Hit count: 605
html
|JavaScript
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
© Stack Overflow or respective owner