SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Jul 2008
    0 Post(s)
    0 Thread(s)

    Open in a new window with javascript


    I have an asp page to search for data. I like to open it in a new window while retain the search values. And I also can resize the window as well as set its attributes like
    height, width,etc.

    I created a js function like this:

    function posttopopup(formname, windowname)
    if (! window.focus)return true;'', windowname);;
    return true;

    on my asp search page:

    <form method="post" action=search.asp" onSubmit="posttopopup(this, 'popupwindow')">
    <input type="button" name="Submit1" value="Search" onclick="if (isDate()) document.Search.submit();">

    I keep getting errors like " has no value..."

    What did I do wrong?


  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Christchurch, New Zealand
    104 Post(s)
    4 Thread(s)
    The simple solution is to make the button a submit button, so that it automatically submits the form without you needing to make any special calls.

    If the function call results in a value that you don't like (returning false for not a date, for example), you can return that value to the onclick event to prevent the submit button from submitting the form.

    A simple way is this:

    Code html4strict:
    <input type="submit" name="Submit1" value="Search" onclick="if (isDate() === false) { return false; }">

    You can make it even simpler like this:

    Code html4strict:
    <input type="submit" name="Submit1" value="Search" onclick="return isDate();">
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Posting Permissions

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