سؤال

I have a Google search bar in my website, which I created with this:

<form method="get" action="https://www.google.com/search">
    <input type="text" name="q"/>
</form>

If I write into the search box stackoverflow, it performs a search in Google with this URL:

https://www.google.com/search?q=stackoverflow

Now, I wanted to modify this to perform a search directly in Google Images or in Google Videos. Note that in order to perform the search stackoverflow in Google Images/Videos I just need to use these URLs:

Images: https://www.google.com/search?q=stackoverflow&tbm=isch
Videos: https://www.google.com/search?q=stackoverflow&tbm=vid

How can I add the parameter tbm to the search using HTML/Javascript?

هل كانت مفيدة؟

المحلول

you can use an nother form elemet. here i used an select box:

<form method="get" action="https://www.google.com/search">
    <input type="text" name="q"/>
    <select name="tbm">
        <option value="">Select</option>
        <option value="isch">Images</option>
        <option value="vid">Video</option>
    </select>
</form>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top