SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard lukeurtnowski's Avatar
    Join Date
    Mar 2003
    Location
    Coronado
    Posts
    1,657
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    problem with a pop-up window

    I'm trying to use this php code to open a pop-up
    PHP Code:
    echo '<a href="/provider_page.php?id='.$ID.'"onclick="window.open(\'/provider_page.php?id=' $ID '','MyWin\',\'width=200,height=300\');"> '
    It gives me an error so when I view the source, this is what I see,
    HTML Code:
    <a href="/provider_page.php?id=4"onclick="window.open('/provider_page.php?id=4MyWin','width=200,height=300');">
    can someone tell me what the deal is?
    Thanks
    "Oh, and Jenkins--apparently your mother died this morning."

  2. #2
    SitePoint Enthusiast
    Join Date
    May 2007
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    Use this code:

    PHP Code:
    echo '<a href="/provider_page.php?id='.$ID.'" onclick="window.open(\'/provider_page.php?id=' $ID '\',\'MyWin\',\'width=200,height=300\');">test</a> '
    PHP Functions Class/Php Stuff: php-classes-functions.blogspot.com
    SMS World: sms-treasure.blogspot.com
    Finance Business India: financebusinessindia.blogspot.com
    Retail Market India: retailmarketindia.blogspot.com

  3. #3
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You didn't escape two of the single-quotes. ashishmat1979's version includes them.

    You don't need to put the URL in twice.
    Code:
    echo '<a href="/provider_page.php?id='.$ID.'"onclick="window.open(this.href,\'MyWin\',\'width=200,height=300\');"> ';
    It's best to avoid using inline event handlers. I suggest you read up on Unobtrusive JavaScript and other JavaScript Best Practices.
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  4. #4
    SitePoint Wizard lukeurtnowski's Avatar
    Join Date
    Mar 2003
    Location
    Coronado
    Posts
    1,657
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    ok, thanks again lenny.
    "Oh, and Jenkins--apparently your mother died this morning."


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
  •