0
次に検索を作成し、すべてのボタンをjavascriptで検索する方法はありますか?これは私のスクリプトで、これまでに...次のボタンを検索するjavascript
<script type="text/javascript">
function setSelectionRange(input, selectionStart, selectionEnd)
{
input.focus();
input.setSelectionRange(selectionStart, selectionEnd);
}
function selectString (input, string)
{
var match = new RegExp(string, "g").exec(input.value);
if (match)
{
setSelectionRange (input, match.index, match.index + match[0].length);
}
}
</script>
<form action="" method="get" onsubmit="selectString(document.getElementById('text'), document.getElementById('search').value);return false;">
<legend>
<font face="verdana">Zoekveld</font face>
</legend>
<input id="search" name="search" type="text" size="75">
<input type="submit" value="Zoeken">
</form>
<form name=form1 method="get">
<legend>
<font face="Verdana">Vind:</font face>
</legend>
<textarea id="text" cols="54" rows="20"></textarea>
</form>
このスクリプトの問題はそれだけで最初のマッチを見つけることができるということです。.. 。
だから私はちょうどにそれを変更した場合:。 するvar一致=新しい正規表現(文字列を、 "I")lastIndexの(input.value)。 うまくいくはずですか? しかし、そうではありません:(javascriptでそのようなnoobであることについて申し訳ありません...(あなたは私のスクリプトを変更する可能性がありますか...それを行う方法やチュートリアルや何かを得ることができる場所を教えてください? – user1339469
例を追加しました。他のマッチを見つけようとしているときにスクリプトがそれに依存しているかどうかわかりません。 – Bergi
私はコードを変更しようとします。すぐにヘルプのためのThx: – user1339469