Click to See Complete Forum and Search --> : Place cursor in Search field on page load


bobafifi
05-01-2003, 09:11 AM
Anybody have a JavaScript to place the cursor in the Search field on page load (like Google) that will work on my site ( http://www.usedflutes.com )?

Thanks,

-Bob

khalidali63
05-01-2003, 09:13 AM
place to code below in the head section of the page

<script type="text/javascript">

function placeCursor(){
document.formName.fieldName.focus();
}

</script>

and then in the body tag...

<body onload="placeCursor()">

bobafifi
05-01-2003, 09:40 AM
Thanks Khalid,
I just tried installing your code on http://www.usedflutes.com/index_test.html like this but it doesn't seem to be working...

<script type="text/javascript">

function placeCursor(){
this.myForm.query.focus();
}

</script>


any ideas?

Thanks again,

-Bob

khalidali63
05-01-2003, 09:43 AM
your link doesn't seem to take me to that page,
the implementation must be wrong,its pretty straight worward..

make sure your link does work

document.myForm.query.focus();

bobafifi
05-01-2003, 09:47 AM
http://usedflutes.com/index_test.shtml (sorry...)

khalidali63
05-01-2003, 09:58 AM
your form element does not have a name attribute.it should be somethinglike this

<form name="myForm" ACTION="http://search.freefind.com/find.html" METHOD=GET>

bobafifi
05-01-2003, 10:15 AM
That did it!
Thanks Khalid :-)

-Bob