It is currently 05 Sep 2010, 03:57




Post new topic Reply to topic  [ 6 posts ] 
 OnFocus 
Author Message

Joined: 23 Mar 2010, 04:43
Posts: 1
Post OnFocus
Hello.
First of all let me thank you for this incredible component. It really helps and saves a lot of time and nerves. )

I have a question:
I want to add OnFocus and OnBlur events to my fields. I've found this string
Code:
$field->html_tag = '<input type="text" name="' . $field->name . '" id="' . $field->name . '" ' . $maxlength . ' ' . $field->field_parameters . ' value="' . $postData_field_value . '"  />';

in 'components/com_aicontactsafe/views/message/view.html.php'.

How do I add OnFocus and OnBlur events to this code correctly so that the field clear it's value when it is clicked on?

thnx in advance


23 Mar 2010, 04:51
Profile
User avatar

Joined: 31 Mar 2009, 09:00
Posts: 1787
Location: Brașov - România
Post Re: OnFocus
You can use something like this:

Code:
$field->html_tag = '<input type="text" name="' . $field->name . '" id="' . $field->name . '" ' . $maxlength . ' ' . $field->field_parameters . ' value="' . $postData_field_value . '" onblur="this.value=\'\'"  />';


But I don't think it's a good idea.
Somebody might want just to modify the text, not to enter it again.

_________________
Alex Dobrin
Algis info


Follow me on Twitter


27 Mar 2010, 15:05
Profile YIM WWW

Joined: 29 Mar 2010, 00:38
Posts: 2
Post Re: OnFocus
Hi, My first post, and I want to say thanks for the fantastic extension. Excellent work.

I also want to use the onfocus event on a request form I started to build. I looked at the tip given and managed to adapt it successfully for a textbox field using this snippet...

onfocus="if (this.value == \'Please enter your full name here\') {this.value=\'\';}"

I'm using the text above in an aics_name textbox field so only this string gets wiped.

My question is; if I want to do something similar with an Editbox field where can I insert the code in view.html.php. What I have in mind is for an aics_message editbox field where I would have...

onfocus="if (this.value == \'Please tell us more about your interest here\') {this.value=\'\';}"

I realise that these mods will only work with each text field type and not all aics_fieldnames. But this will still be very useful.

Appreciate any tips on this.


29 Mar 2010, 00:54
Profile
User avatar

Joined: 31 Mar 2009, 09:00
Posts: 1787
Location: Brașov - România
Post Re: OnFocus
In the same file, look for the lines starting with :
Code:
$field->html_tag = '<textarea name=

You need to make similar changes on this lines as you did for the input field.

_________________
Alex Dobrin
Algis info


Follow me on Twitter


29 Mar 2010, 07:35
Profile YIM WWW

Joined: 29 Mar 2010, 00:38
Posts: 2
Post Re: OnFocus
Thanks Alex,

Worked a treat. I just added it in the first 'if' clause, not sure if its needed in the 'else' section.

Added in Line 777

$field->html_tag = '<textarea name="' . $field->name . '" id="' . $field->name . '" ' . $cols . ' ' . $rows . ' ' . $field->field_parameters . ' onkeydown="checkEditboxLimit('.$this->profile->id.',\''.$field->name.'\', '.$field->field_limit.')" onkeyup="checkEditboxLimit('.$this->profile->id.',\''.$field->name.'\','.$field->field_limit.')" onchange="checkEditboxLimit('.$this->profile->id.',\''.$field->name.'\','.$field->field_limit.')" onfocus="if (this.value == \'Testing\') {this.value=\'\';}">' . $model->revert_specialchars($postData_field_value) . '</textarea>';

Changed the text to my final tip text after testing.


29 Mar 2010, 14:03
Profile
User avatar

Joined: 31 Mar 2009, 09:00
Posts: 1787
Location: Brașov - România
Post Re: OnFocus
Happy to hear that. :)

_________________
Alex Dobrin
Algis info


Follow me on Twitter


29 Mar 2010, 14:21
Profile YIM WWW
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © phpBB Group.