Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    new guy - newb java help

    Hello all, I am an admin, and I am building a radial button search option on a webpage. It works fine, except I cant seem to get it to open the results in a new window. I tried using the "window.open" but it didnt work. Any assitance would be appreciated! Also, I am not a great java programmer, and what you see below is the extent of my knowledge
    Thanks in Advance!!

    ===================CODE===============
    <html>
    <body>
    <script language="JavaScript">eng = 'http://www.google.com/search?q=';</script>
    Search:
    <input type="text" id="searchterms">
    <input type="button" value="Search" onload="" onclick="window.location = eng + escape(document.getElementById('searchterms').value); return false;">
    <br />
    <input type="radio" onclick="eng = this.value;" checked name="sengines"
    value="http://www.google.com/search?q=" />Google
    <input type="radio" onclick="eng = this.value;" name="sengines"
    value="http://support.citrix.com/search/basic/?searchQuery=" />CTX KB
    <input type="radio" onclick="eng = this.value;" name="sengines"
    value="http://support.microsoft.com/search/default.aspx?mode=r&query=" />MS KB
    </body>
    </html>

  • #2
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,981
    Thanks
    56
    Thanked 557 Times in 554 Posts
    Code:
    onclick="window.open(eng + escape(document.getElementById('searchterms').value)); return false;"

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,081
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    This is the JavaScript forum. Java and Javascript are entirely different programming languages, in spite of the confusingly similar names. Rather like Austria and Australia!

    You mean a radio button - not a radial button.


    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,198
    Thanks
    80
    Thanked 4,453 Times in 4,418 Posts
    As a minor point, there is no reason to use return false from an <input type="button">. Buttons don't perform any action at all except what you provide for them in JavaScript. Yes, you do need the return false for <input type="submit">, but not for button.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •