I tried connecting the first text box, so it would turn it into a URL, and then when 'search' is clicked, it would jump to that website, not sure if it's impossible, or i'm just clueless, but would really appreciate some help, thank you in advance!
<html>
<head>
</head>
<body>
<script type="text/javascript">
function link() {
var link_s = document.getElementById('link_id').value;
document.getElementById('link_str').innerHTML = link_s.link()
}
</script>
<h2> Search box </h2>
<input type='text' id='link_id'>
<input type='button' id='link_str' value='Search' onClick='link()'>
</body>
<html>
Try this JavaScript:
function goTo()
{
location.href = document.getElementById('link_id').value;
}
and change the onclick
in the HTML:
<input type='text' id='link_id'>
<input type='button' id='link' value='Search' onClick='javascript:goTo()'>
Edit:
If you want to follow the unobtrusive JavaScript way, you would move the onclick
completely into your JavaScript code, and remove it in the HTML:
document.getElementById('link').onclick = function()
{
location.href = document.getElementById('link_id').value;
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With