Click to See Complete Forum and Search --> : cursor in textbox


neil9999
08-31-2003, 11:44 AM
Hi,

Is it possible to put the mouse cursor inside the textbox?

Thanks,

Neil

David Harrison
08-31-2003, 11:46 AM
You mean something like this:

<input type="text" style="cursor:default;">

neil9999
09-01-2003, 06:16 AM
Sorry, that doesn't seem to work. My script's attatched.

Thanks for your help,

Neil

lillu
09-01-2003, 06:29 AM
Hi,

Just put this into the body tag:

<body bgcolor="#FF0000" onload="javascript:document.answer.focus();">

neil9999
09-01-2003, 06:36 AM
Thanks, but it still won't work. Attatched is the script now.

Thanks,

neil

lillu
09-01-2003, 08:04 AM
I made 3 changes in next1() function:

1. add this line:

function next1(){

document.getElementById('answer').focus();

2. remove all occurence of this line

document.getElementById('answer').value='answer';

3. add this line at the very end of the function, just before the final curly braces:

document.getElementById('answer').value='';
}

Khalid Ali
09-01-2003, 08:26 AM
This will work.Make sure you replace formName with the form elements name and textFieldName with the particular textfields name

<body onload="document.formName.textFieldName.focus();">

lillu
09-01-2003, 10:54 AM
Khalid,

That will not work.

1. There's no form tag in his script.
2. I was wrong at first at this too, until I saw that his script not only requires the cursor to be set at onload (which fires only when the page loaded but no more) but from within a function every time a next question is called.

neil9999
09-01-2003, 12:46 PM
Thanks, I've got it perfect now using lilu's last suggestion (thanks anyway Khalid). I don't need the cursor in the box when the page loads, just when it's asking you a question so you don't need to keep clicking in the textbox.

Here's my final, working script.

Thanks,

Neil