How is it possible to put cursor at the end of field input text?

QuestionsHow is it possible to put cursor at the end of field input text?
toki asked 12 years ago

Hello,

In add and edit dialog forms when focus a field input, cursor wait beginning of text. How is it possible to put cursor at the end of field input text?

regards…

5 Answers
Abu Ghufran answered 12 years ago

This could be the possible JS settings.

$grid["add_options"]["afterShowForm"] = 'function(formid) { jQuery("#"+formid + " > input:last").focus(); }';
$g->set_options($grid);

Well, this is just to give you an idea, you can have your JS code inside that function, to focus on last field.

toki answered 12 years ago

Hi Abu,

I do not want to focus on last field input. I want to see cursor at the end of each field input text on focus if edit dialog form open . set cursor position like seltext+1(at the end of text) on focus each input if it is not null.

regards…

Abu Ghufran answered 12 years ago

Hello,

I've provided you interface to play and put jquery implementation in functions body.
I'd suggest to look at stackoverflow to know the jquery code for our desired implementation.

https://www.google.com/search?q=jquery+select+on+focus

toki answered 12 years ago

Abu,

$grid["add_options"]["afterShowForm"] = 'function(formid) { jQuery("#detail").focus().select(); }';
$grid["edit_options"]["afterShowForm"] = 'function(formid) { jQuery("#detail").focus().select(); }';

this codes select text in field input which named as detail.

Why I ask my question to you firstly because If there is some prepared phpgrid function with related matter.Otherwise I spend a lot of time to solve by myself.

Yes, I must try to use jquery in phpgrid functions.

Thank you.

toki answered 12 years ago

Abu,

$grid["edit_options"]["afterShowForm"] = 'function(formid) {jQuery("#detail").focus().val($("#detail").val());

this code works for set cursor position at the end of text on input focus in edit dialog form.

It maybe helps for someone.
Regards…

Your Answer

14 + 5 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?