私はゼロのJavaScriptを知っています。小さなスクリプトを変換して組み合わせることで、ほとんどの要件を達成しました。ただし、以下で説明する時点で、要件を完全に解決できませんでした。
定数テキストの前にもハイパーリンク ID の値を出力したいと考えています。 jqueryは使いません。
例えば「当分の間、返信しています」と書いているだけです。
ただし (ハイパーリンク ID = 6 と仮定) 「当分の間、6 が返信されます」と記述する必要があります。
この SO Q&A を読みましたが、その恩恵を受けることができませんでした。( JS: appendChild() 内で変数を連結する方法は? )
body タグ内の JS
function reply_comment (id) {
var LinkId = document.getElementById('parent_id');
LinkId.value = id;
var message = document.createTextNode(" is being replied by the time being.");
document.getElementById('print_id').appendChild(message);
document.getElementById("focus_id").focus();
}
HTML
<!-- codes given above -->
<script type="text/javascript">
... ... ...
</script>
<!-- codes given above -->
<!-- when clicked on the hyperlink, store the hyperlink id value (id value is an unsigned integer) -->
<!-- print the stored id from hyperlink into the value="{unsigned integer id}" part of input ( type:text and id="parent_id" )-->
<!-- focus on comment form's input ( type:text and id="focus_id" ) -->
<!-- print preset message between span tags ( span tag id="print_id" ) -->
<a class="rep" href="#focus_id" onclick="reply_comment(this.id);" id="6" rel="nofollow">reply comment</a>
<p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p><p>filling words</p>
<span id="print_id"></span>
<form>
<label for="focus_id">Focus the cursor below</label>
<input type="text" id="focus_id" name="focus_id">
<label for="parent_id">Paste parent_id below</label>
<input type="text" id="parent_id" name="parent_id" value="">
</form>