Reply link, auto addition of text to textarea in XHTML Strict?
I'm trying to add a link next to each comment on my blog, where when you click on the word "Reply", "@Name" automatically adds to the comment form's textarea below (it also jumps to the form by anchor link).
This is what I'm currently using:
<script type="text/javascript">
/* <![CDATA[ */
function reply(text) {
document.form.comment.value += text;
}
/* ]]> */
</script>
And for each link (multiple on page)...
<a href="#form" onclick="reply('@<?php echo $name; ?>: ');">Reply</a>
And the form...
<form name="form" id="form"...
<textarea name="comment" id="comment"...
Assuming I didn't typo any of it, but it works just fine.
The problem:
I'm coding my site in XHTML Strict and upon checking its validation, the <form>
tag isn't allowed to have a name
attribute. So now I'm wondering if there's a way I can get around it? Is there another method that doesn't require multiple <script>
's for each link? Thanks in advance.
在文本区域添加一个ID,并使用document.getElementByID。
链接地址: http://www.djcxy.com/p/88778.html