boardom Forum Index boardom
b2 message board
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

smart comments form

 
Post new topic   Reply to topic    boardom Forum Index -> Hacks
View previous topic :: View next topic  
Author Message
mikelittle



Joined: 11 May 2002
Posts: 376
Location: UK

PostPosted: Tue Feb 18, 2003 2:02 am    Post subject: smart comments form Reply with quote

The other day someone (blog17?) asked me if it was possible to have the comments form automatically remove the default values when you click on an input box; so that you don't end up with 'namefred'. I just remembered to look into it and here is the result:

In b2comments.php, at line 50, change

Code:

<form action="<?php echo $siteurl; ?>/b2comments.post.php" method="post">
   <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
   <input type="hidden" name="redirect_to" value="<?php echo htmlspecialchars($HTTP_SERVER_VARS["REQUEST_URI"]); ?>" />

   <p class="commentfield">
   name<br />
   <input type="text" name="author" class="textarea" value="<?php echo $comment_author ?>" size="20" tabindex="1" />
   </p>

   <p class="commentfield">
   email<br />
   <input type="text" name="email" class="textarea" value="<?php echo $comment_author_email ?>" size="20" tabindex="2" />
   </p>

   <p class="commentfield">
   url<br />
   <input type="text" name="url" class="textarea" value="<?php echo $comment_author_url ?>" size="20" tabindex="3" />
   </p>

   <p class="commentfield">
   your comment<br />
   <textarea cols="40" rows="4" name="comment" tabindex="4" class="textarea">comment</textarea>
   </p>

To read
Code:

<form action="<?php echo $siteurl; ?>/b2comments.post.php" method="post">
   <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
   <input type="hidden" name="redirect_to" value="<?php echo htmlspecialchars($HTTP_SERVER_VARS["REQUEST_URI"]); ?>" />

   <p class="commentfield">
   name<br />
   <input type="text" name="author" class="textarea" value="<?php echo $comment_author ?>" size="20" tabindex="1"
  onfocus="this.value=(this.value=='name') ? '' : this.value;" onblur="this.value=(this.value=='') ? 'name' : this.value;" />
   </p>

   <p class="commentfield">
   email<br />
   <input type="text" name="email" class="textarea" value="<?php echo $comment_author_email ?>" size="20" tabindex="2"
  onfocus="this.value=(this.value=='email') ? '' : this.value;" onblur="this.value=(this.value=='') ? 'email' : this.value;" />
   </p>

   <p class="commentfield">
   url<br />
   <input type="text" name="url" class="textarea" value="<?php echo $comment_author_url ?>" size="20" tabindex="3"
  onfocus="this.value=(this.value=='url') ? '' : this.value;" onblur="this.value=(this.value=='') ? 'url' : this.value;" />
   </p>

   <p class="commentfield">
   your comment<br />
   <textarea cols="40" rows="4" name="comment" tabindex="4" class="textarea"
  onfocus="this.value=(this.value=='comment') ? '' : this.value;" onblur="this.value=(this.value=='') ? 'comment' : this.value;" >comment</textarea>
   </p>


This will automatically clear the input field when you click on it or tab to it.
If you leave the field empty it will put the default back.

Hope this helps,
Mike
_________________
Mike Little
http://zed1.com/journalized/
"Share what you know. Learn what you don't."
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
dev



Joined: 16 Feb 2003
Posts: 6
Location: Estados Unidos

PostPosted: Tue Feb 18, 2003 2:14 am    Post subject: Reply with quote

I remember Grace, from Starkfrenzy, using it in her cafelog code. But it is very refreshing to see that code be used again.
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
mikelittle



Joined: 11 May 2002
Posts: 376
Location: UK

PostPosted: Tue Feb 18, 2003 2:26 am    Post subject: Reply with quote

I can't remember where I got the idea for this code from. It wasn't Grace's site (which doesn't seem to be using anything now), but I do remember it was a search form..
*shrugs*

Mike
_________________
Mike Little
http://zed1.com/journalized/
"Share what you know. Learn what you don't."
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
GamerZ



Joined: 15 May 2002
Posts: 537
Location: Singapore

PostPosted: Tue Feb 18, 2003 10:22 am    Post subject: Reply with quote

i like the sms feature on the page
_________________

++ GamerZ.Per.Sg - Complex Simplicity
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
.Chris



Joined: 30 Apr 2002
Posts: 186
Location: Hawaii

PostPosted: Tue Feb 18, 2003 8:28 pm    Post subject: Reply with quote

Hi Mike,

I use this, always have. Maybe that's where you saw it? Smile I think I had a post about it for tank @ tankgreen.com.

I got it and other stuff from http://anarchos.xs.mw/formtricks.phtml


Last edited by .Chris on Wed Feb 19, 2003 5:51 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
wteening



Joined: 12 Jul 2002
Posts: 71

PostPosted: Wed Feb 19, 2003 10:34 am    Post subject: Reply with quote

Great! I hated those naamSomething idiots Very Happy
Back to top
View user's profile Send private message Visit poster's website
chipperspragish



Joined: 07 Apr 2003
Posts: 9
Location: Seattle

PostPosted: Tue Apr 08, 2003 5:03 am    Post subject: Reply with quote

Awesome! Thanks for the great hack! Very Happy
Back to top
View user's profile Send private message Visit poster's website AIM Address
xytx



Joined: 24 May 2003
Posts: 48

PostPosted: Sun May 25, 2003 9:45 pm    Post subject: Reply with quote

great hack! thanks
Back to top
View user's profile Send private message
dodo



Joined: 25 Jan 2002
Posts: 35

PostPosted: Wed May 28, 2003 10:45 pm    Post subject: Reply with quote

neat, thanks!
_________________
http://pure-essence.net

b2 rocks
Back to top
View user's profile Send private message Visit poster's website
epolady



Joined: 30 Jul 2002
Posts: 800
Location: Texas

PostPosted: Fri May 30, 2003 5:37 am    Post subject: Reply with quote

Thank you for this. Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    boardom Forum Index -> Hacks All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB 2 © 2001, 2002 phpBB Group