SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Feb 2011
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    This should be easy for you Pro's!

    Hi guys,

    I am new to javascript so thought I's post here for some advice.

    I'm trying to complete a simple keyword search where the keyword is forwarded on the end of a url. I have this working-(ish), but at the moment it's doing this:

    1. Add keyword and hit send
    2. Opens a new window to confirm search term.
    3. Clicking that sends you to the target site with keyword on the end.

    I'm trying to bypass stage 2 and go straight to 3 from step 1.

    Code so far:

    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <
    html xmlns="http://www.w3.org/1999/xhtml">
    <
    head>
    <
    meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <
    title>Untitled Document</title>

    <
    SCRIPT LANGUAGE="JavaScript">
    function 
    searchFunc() {
    var 
    newWindow window.open("about:blank""searchValue");
    var 
    searchValue document.search.queryField.value;
    var 
    keywordSearch document.search.keyword.value;
    newWindow.document.write("<a href='" keywordSearch searchValue "' target = 'blank'>Confirm Search</a>\n");
    }
    </script>


    </head>

    <body>
    <form name=search>
    <input type=hidden name=keyword value="http://www.domain.com/default.aspx?st=FT&ss=">
    <input type=text size=25 name="queryField">
    <input type=button value="Search" onClick="searchFunc()">
    </form>

    </body>
    </html> 

    I've tried deleting some of the code but always lose functionality. Any advice?

  2. #2
    SitePoint Member
    Join Date
    Feb 2011
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Never mind, got it working.


Bookmarks

Posting Permissions

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