0

hello
I wrote code for a scramble word game and I am trying to set focus everytimge I click on check button..I've got it so it will set focus when I start game, but whenever I put put setFocus() on the onclick of the button it will not work...
is there any way the I can have two procedures for onclick...like

<input id="inbox" type="text" /><input type="button" value="check" onclick="guess()" "setFocus()"/>

I also want to selectall if the word is incorrect

not sure how to go about doing this..I did research on this problem, but they all give me examples on applying just one thing to the onclick not two..
thank you

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by msqueen082
1

Msqueen,

Javscript written in an HTML onclick/onchange/onblur etc. is nothing more than the contents of an anonymous function. Therefore, simply separate statements with semicolons.

<... onclick="guess(); setFocus();" ...>

Airshow

0

That fixed my problem of focus,,but the select all didn't work...here is how I coded a funtion for select all and I also put it in the onclick of the button as
selectAll();

function selectAll()
		{
			document.getElementById("inbox").selectAll();
			}// set select all to the text box
0

Answered my own question..thank you for your help

It was that I put selectAll in my function instead of select..

function selectAll()
        {
            document.getElementById("inbox").select();
            }// set select all to the text box

Edited by Dani: Fixed formatting

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.