Question

What im trying to do is to make a simple textbox/button to search on youtube, the simpliest way possible.

The JavaScript

<script type="text/javascript">
function search()
var value = getelementbyid="search-box"
openinanewwindow = https://www.youtube.com/results?search_query='value'
</script>

The html

<form>
<input type="text" id="search-box">
<input type="button" id="search-btn" value="Search" onClick="search()">
</form>

Please ignore the way i wrote the script i just tried to explain my objective the simplest way possible and i know i didn't applied any real/correct terms.

Any help is greatly appreciated and thanks in advance.

Was it helpful?

Solution

<form>
    <input type="text" id="search-box"></input>
    <input type="button" id="search-btn" value="Search"></input>
</form>

document.getElementById("search-btn").onclick=function(){
        var value=document.getElementById("search-box").value;
        window.open("https://www.youtube.com/results?search_query="+value);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top