How implement I'm feeling Lucky in html?

Viewed 9596

I have been trying to implement a form that goes to either normal Google search results or it's first search result. This is what I have tried.

<form action="https://google.com/search">
    <input type="text" name="q" class="box">
    <br>
    <div>
        <input type="submit" value="Google Search" class="button">
        <input type="submit" value="I'm Feeling Lucky" class="button" formaction="https://google.com/search?&btnI=1">
    </div>
</form>

I know for a fact that if I search for let's say "AMD" then the I'm feeling lucky URL should be "https://google.com/search?q=AMD&btnI=1"

However, I am not able to add that "&btn1" at the end of the URL.

3 Answers

It will work fine.

<form action="https://google.com/search">
    <input type="text" name="q" class="box">
    <br>
    <div>
        <input type="submit" name="btnK" value="Google Search" class="button">
        <input type="submit" name="btnI" value="I am Feeling Lucky" class="button">
    </div>
</form>

Use <button type="submit"> instead:

<form action="https://google.com/search">
    <input type="text" name="q" class="box">
    <br />
    <div>
        <button type="submit" class="button">Google Search</button>
        <button type="submit" name="btnl" value="1" class="button">I'm Feeling Lucky</button>
    </div>
</form>

The only thing you have to do is to give the name "btnI" to the input.

<input type="submit" value="I'm feeling lucky" name="btnI">
Related