MyBB Community Forums

Full Version: Focus on text box new reply
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, I hope I'am in the right area of this forum with my question.

( secondly, sorry for my poor English )

I'm working with Mybb v1.6, Firefox & Internet Explorer.

My question:
When putting a new reply, you first have to click into the text field before you can typing your reply.
Is there a way to put a focus on this textarea before ?
I mean, that the cursor is already within this text field and you can type your reply directly without the mousclick on the textfield first.

Kind regards,

Wink
Put this in your global or showthread template:

<script type="text/javascript" language="JavaScript">
document.forms['quick_reply_form'].elements['message'].focus();
</script>

If this helped please rate me.
You don't need to use javascript to achieve this. You can use CSS.

Simply add this to your global stylesheet.

textarea:focus {
	border: 1px solid #000;
}

What this will do (if I apprehend what you want to achieve), is when the textarea is clicked/focused, it will change its border color to black. You can substitute the border color with whatever if this is what you're wanting to do.
I think what he wants is to have an autofocus on the quickreply box.
Thanks both of you for your quick answers. Smile

But it isn't for a quick-reply but for a normal reply.
For a quick reply, it isn't a big problem to put the focus, but for a new reply, it's a little bit more difficult because in the script you have 2 text-boxes:
(editor.js)

- the text box with the subject of the thread.
- the text box where the message (the reply) comes.

My question is to have the focus on this reply-text box.
At this moment I have no focus at all.
( not with Firefox, not with IE )
Then place this code
<script type="text/javascript" language="JavaScript">
document.forms['input'].elements['message'].focus();
</script>

In newreply and newthread template
It does not work...

I even tried to put 'textarea.focus()' into the editor.js, and this don't work even.
Worse, in this case the tool bars are even not dipslayed.
*lol*

On phpbb forums, you will have the same problem.

Will mybb-forums be the first to have a solution for this ? Big Grin

( I'll check later on a VBulletin forum )
Vbulletin, the same. Confused
( with Firefox & IE )
<script type="text/javascript" language="JavaScript">
document.forms['***replace this with form name***'].elements['***replace this with input name***'].focus();
</script>
(2011-03-07, 03:18 AM)Darth Stabro Wrote: [ -> ]<script type="text/javascript" language="JavaScript">
document.forms['***replace this with form name***'].elements['***replace this with input name***'].focus();
</script>

My question is, 'how to implement this in mybb ?'

Smile