Call function in comment field to pull cookies or default
-
This is my goal: I want my comments form fields to be filled in automatically with cookies if they exsist and if they do not I want the fields to default to “Name”, “Email”, “Url” when not focused (onblur).
This is what I’ve done: I’ve included the following atributes to the <input> fields:
onfocus="if(this.value==this.defaultValue)value=''" onblur="if(this.value=='')value=this.defaultValue;"
For the value of the <input>, I’ve put:
value="<?php commentauthor($comment_author,Name) ?>"
And in the header, I've included the following script:
<script>
function commentauthor(cookie,default)
{
if (cookie)
return cookie;
else
return default;
}
</script>
Problems: When I load the page, it says that my function is undefined (fatal error). Did I do something wrong in defining the function?
Also, is there a better way to do this, maybe something built into Word Press that I don’t know about? This should work fine, I think if I can get it to work, but any other suggestions?
- The topic ‘Call function in comment field to pull cookies or default’ is closed to new replies.