SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    SitePoint Zealot
    Join Date
    Mar 2004
    Location
    united states
    Posts
    178
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    problem formatting call to window.open()

    Hello

    I am trying to open a new browser page using window.open
    If I do the following, everything works out fine:
    Code:
    window.open('myPage.php?param1=value1&param2=value2','_blank','status=no,scrollbars=yes,location=no,height=200,width=200');
    The problem is that the URL parameters, width and height of the page are parameters that I receive as variables.
    That lead me to the following attempt:
    Code:
    function showFullSizePhoto(URLParams, width, height) {
      var url = "myPage.php?" + URLParams;	
      parameters = "status=no,scrollbars=yes,location=no,height=" + height + ", width=" + width;
      var target = "'" + url + "','_blank','" + parameters + "'";
      window.open(target);
    }
    Unfortunately, this doesn't work.
    It seems like there is a syntax problem of using the single quotes.
    Can anyone show me what the correct syntax should be?

    thanks

  2. #2
    SitePoint Evangelist
    Join Date
    Sep 2003
    Location
    San Diego, CA
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's working code...
    Code:
    function showFullSizePhoto(URLParams, width, height) {
      var url = "myPage.php?" + URLParams;	
      parameters = "status=no,scrollbars=yes,location=no,height=" + height + ", width=" + width;
      window.open(url,'_blank',parameters);
    }
    You dont't need the target variable...and maybe someone else can explian it better...but that code does work. You may be able to figure out why by looking at it (your variables were already strings, so there was no need to put quotes around it...it was a string in a string!)

  3. #3
    SitePoint Zealot
    Join Date
    Mar 2004
    Location
    united states
    Posts
    178
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks, you are right and now it works

  4. #4
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm trying to open a new window with "$query_data[1]" value and showing this to the open window. Can any 1 give the solution .... plz

    =====================================================

    function display(temp)
    {
    var win1 = window.open("update.php?temp", "myWindow", "toolbar=0,width=800,height=400");
    }

    echo "<A HREF=# onClick = display('$query_data[1]')> View Details </A>";

  5. #5
    SitePoint Evangelist
    Join Date
    Sep 2003
    Location
    San Diego, CA
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    change your display function to
    Code:
    function display(temp)
    {
    var win1 = window.open("update.php?temp=" + temp, "myWindow", "toolbar=0,width=800,height=400");
    }
    The querystring in the new page will be temp (that will contain your variable).

    Also, I don't know PHP, so you may want to make sure the php code is writing your variable?

  6. #6
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for ur help, now it works..

  7. #7
    SitePoint Evangelist
    Join Date
    Sep 2003
    Location
    San Diego, CA
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, great!

  8. #8
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In the following way I can send 1 temp value , plz tell me how i send more than 1 value ?

    ===================================================

    function display(temp)
    {
    var win1 = window.open("update.php?temp=" + temp, "myWindow", "toolbar=0,width=800,height=400");
    }

  9. #9
    SitePoint Evangelist
    Join Date
    Sep 2003
    Location
    San Diego, CA
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just add more values like so...

    Code:
    function display(temp1,temp2,temp3,temp4,temp5,temp6)
    {
    var win1 = window.open("update.php?temp1=" + temp + "&temp2=" + temp2 + "&temp3=" + temp3 + "&temp4=" + temp4 + "&temp5=" + temp5 + "&temp6=" + temp6, "myWindow", "toolbar=0,width=800,height=400");
    }
    and call it like...
    Code:
    display('value1','value2','value3','value4','value5','value6');

  10. #10
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How can i post input text box's data to the window.open form after submitting a page.

  11. #11
    SitePoint Evangelist
    Join Date
    Sep 2003
    Location
    San Diego, CA
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This will submit a form AND open a window with the value of the text box...

    Code:
    <script>
    function display(temp)
    {
    var win1 = window.open("update.php?temp=" + temp, "myWindow", "toolbar=0,width=800,height=400");
    }
    </script>
    <form action="somepage.php" method="POST" onsubmit="display(this.txt.value);">
    <input type="text" name="txt">
    </form>

  12. #12
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I want to pass two/more values in new window , while can carry both input text value and other type value. I'm using this ---
    Code:
    <FORM METHOD="POST" ACTION="<? echo $PHP_SELF ?>" >
    echo '<INPUT TYPE="TEXT" NAME=takenby1 SIZE="10">';
    
    <INPUT TYPE=SUBMIT VALUE=Update onClick=display('$tmp1',this.takenby1.value)>
    But this contain error called "this.takenby1.value is null"

  13. #13
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I got the solution by myself


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
  •