locked
populating new window with my textbox text into google search text box RRS feed

  • Question

  • User842813459 posted

    hi plz can any body help,

    in my form i have a texbox and buton

    after entering text in my text box the same text has to be pushed in to google serch text box.

    either javascript or c#

    Friday, October 8, 2010 6:48 AM

Answers

  • User1224194097 posted

    Try this

    <script type="text/javascript">
        function searchGoogle() {
            window.location.href = 'http://www.google.com/search?hl=en&q=' +
                                           document.getElementById('<%= txtSearch.ClientID %>').value;
        }
    </script>
    
    <asp:TextBox ID="txtSearch" runat="server"></asp:TextBox>
    <button onclick="searchGoogle();">
        Search</button>

    If you want to open a popup window with search text, use this

    window.open('http://www.google.com/search?hl=en&q=' +
                                   document.getElementById('<%= txtSearch.ClientID %>').value);

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, October 8, 2010 8:16 PM