私は少しの問題があります。私は、ユーザーがコピーするURLを入力するフォームを持っています。これは常に同じようにフォーマットされます。
http://www3.google.com/register.php?key=12334123フィールドを最初のフィールドに基づいてJavascriptで入力してください
私は上記の入力に基づいて2つのフィールドに値を設定できます。
フィールド1はキー番号になり、サーバ(サブドメイン)
フィールド2であろう。
私は現在、動作するものを作っていますが、私がやっているやり方とは対照的に、正規表現を使って行う方が良いと思います。
これはJavaにはあまり熱心ではありませんが、これは私の挑戦です。どんな助けでも大歓迎です!
<script language="javascript">
function urlbreaker(url)
{
var startserver = document.form1.url.value.search(/www/)
document.form1.server.value = document.form1.url.value.substr(startserver, 4)
var startkey = document.form1.url.value.search(/=/)
document.form1.key.value = document.form1.url.value.substr(startkey+1, 10)
}
</script>
<form id="form1" name="form1" method="post" action="">
<p>
<label for="url">input url:</label>
<input type="text" name="url" id="url" onblur="urlbreaker()" />
http://www3.google.com/register.php?key=12334123</p>
<p>
<label for="server">Server:</label>
<input type="text" name="server" id="server" />
should be www3</p>
<p>
<label for="key">key</label>
<input type="text" name="key" id="key" />
should be 12334123</p>
</form>
それはトリックでした!どうもありがとう! – Blaine