View previous topic :: View next topic |
Author |
Message |
mikelittle
Joined: 11 May 2002 Posts: 376 Location: UK
|
Posted: Tue Feb 18, 2003 2:02 am Post subject: smart comments form |
|
|
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 |
|
 |
dev
Joined: 16 Feb 2003 Posts: 6 Location: Estados Unidos
|
Posted: Tue Feb 18, 2003 2:14 am Post subject: |
|
|
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 |
|
 |
mikelittle
Joined: 11 May 2002 Posts: 376 Location: UK
|
Posted: Tue Feb 18, 2003 2:26 am Post subject: |
|
|
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 |
|
 |
GamerZ
Joined: 15 May 2002 Posts: 537 Location: Singapore
|
Posted: Tue Feb 18, 2003 10:22 am Post subject: |
|
|
i like the sms feature on the page _________________
++ GamerZ.Per.Sg - Complex Simplicity |
|
Back to top |
|
 |
.Chris
Joined: 30 Apr 2002 Posts: 186 Location: Hawaii
|
Posted: Tue Feb 18, 2003 8:28 pm Post subject: |
|
|
Hi Mike,
I use this, always have. Maybe that's where you saw it? 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 |
|
 |
wteening
Joined: 12 Jul 2002 Posts: 71
|
Posted: Wed Feb 19, 2003 10:34 am Post subject: |
|
|
Great! I hated those naamSomething idiots  |
|
Back to top |
|
 |
chipperspragish
Joined: 07 Apr 2003 Posts: 9 Location: Seattle
|
Posted: Tue Apr 08, 2003 5:03 am Post subject: |
|
|
Awesome! Thanks for the great hack!  |
|
Back to top |
|
 |
xytx
Joined: 24 May 2003 Posts: 48
|
Posted: Sun May 25, 2003 9:45 pm Post subject: |
|
|
great hack! thanks |
|
Back to top |
|
 |
dodo
Joined: 25 Jan 2002 Posts: 35
|
|
Back to top |
|
 |
epolady
Joined: 30 Jul 2002 Posts: 800 Location: Texas
|
Posted: Fri May 30, 2003 5:37 am Post subject: |
|
|
Thank you for this.  |
|
Back to top |
|
 |
|