Selecting text of field when cliked.

Hi, i need select the text when cliked in a field.

i did a function javascript named selectall:
in event javascript cliked i assign this function to field:

this is function:

document.F1.myfield.focus();
document.F1.myfield.select();

But this do not works!.
if i set an alert to this funtion, it shows the message.

i don’t think so there is any problem in upper script because it’s working good on my pc but there is an other way
try below code and write in head
<script language=“JavaScript”>
function highlight(field) {
field.focus();
field.select();}</script>
and write below code in input field tag
onClick='highlight(this);