[solved]Blank onfocus With Comment Forms

If you have any problems with Fusion News, post your problems here and we'll help you out as soon as possible.

[solved]Blank onfocus With Comment Forms

Postby MacMuttonchops » Fri Mar 05, 2010 3:46 am

Hey all,

I've edited my comments.php to put a value inside the comments form (instead of outside like in the templates) and now I'm trying to get the value disappear when the user clicks inside the form box. However, adding a simple
Code: Select all
onfocus="this.value=''"

isn't cutting it, as I'm getting all kinds of errors when I reload. Anyone know of a better solution?

Thanks!
MacMuttonchops
Newbie
 
Posts: 2
Joined: Fri Mar 05, 2010 3:44 am

Re: Blank onfocus With Comment Forms

Postby joshua.s.belanger » Mon Mar 08, 2010 2:13 pm

Can you post or PM me the comments.php file please?
-Josh
User avatar
joshua.s.belanger
FN Follower
 
Posts: 250
Joined: Wed Jun 03, 2009 2:54 pm

Re: Blank onfocus With Comment Forms

Postby joshua.s.belanger » Wed Mar 10, 2010 4:20 pm

I was able to get it to work with a javascript function... In comments.php find:
Code: Select all
$comlen = '';

Delete that line.

Find:
Code: Select all
$extras = show_extras ('comment_form', 'comment', $smilcom, $bbc);


Just above add:
Code: Select all
   $comlen = <<< html
<script type="text/javascript">
function clearText(field){
    if (field.defaultValue == field.value) field.value = '';
    else if (field.value == '') field.value = field.defaultValue;

}
</script>
html;


Now for you form elements they should look like:
Code: Select all
<input type="text" size="$1" name="name" id="name" value="Name" onFocus="clearText(this)" onBlur="clearText(this)" />


Let me know how that works.
-Josh
User avatar
joshua.s.belanger
FN Follower
 
Posts: 250
Joined: Wed Jun 03, 2009 2:54 pm

Re: Blank onfocus With Comment Forms

Postby MacMuttonchops » Thu Mar 11, 2010 3:46 am

Thanks! Works perfect now. I think you made a typo in your code though:

Code: Select all
<input type="text" size="$1" name="name" id="name" value="Name" onFocus="clearText(this)" onBlur="clearText(this)" />


I had to add a " and remove a > to get it to work. Just thought I'd post that in case someone else was using this to get it to work.

Thanks again! :D
MacMuttonchops
Newbie
 
Posts: 2
Joined: Fri Mar 05, 2010 3:44 am

Re: Blank onfocus With Comment Forms

Postby joshua.s.belanger » Thu Mar 11, 2010 2:37 pm

oops! Nice catch. I updated my original post to make it easier for people.
-Josh
User avatar
joshua.s.belanger
FN Follower
 
Posts: 250
Joined: Wed Jun 03, 2009 2:54 pm


Return to Help and Support

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest

cron