I have the following HTML/jQuery code that generates some links.
HTML
<input type="text" id="text" placeholder="Enter text" autofocus />
<a id="link1" class="btn btn-info" href="#" target="_blank"> Search 1 </a>
<a id="link2" class="btn btn-info" href="#" target="_blank"> Search 2 </a>
<a id="link3" class="btn btn-info" href="#" target="_blank"> Search 3 </a>
jQuery
<script>
window.onload = function(){
var sel = document.getElementById('text');
sel.onchange = function () {
document.getElementById("link1").href = "http://example.com/action?queryString=" + this.value;
document.getElementById("link2").href = "http://example.com/searchall.php?search=" + this.value;
document.getElementById("link3").href = "http://example.com/dashboard.aspx?term=" + this.value;
document.getElementById("text").focus();
}
};
</script>
On the 2nd search link, I'm looking to implement a change wherby if the value entered is an IP address, then the URI is changed. e.g.
document.getElementById("link2").href = "http://example.com/ipsearch.php?ip=" + this.value;
I just don't have a clue on where to start with this change.
Any helps would be greatly appreciated.