Thread: Pop up window

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    21
    Rep Power
    0

    Pop up window


    I want to pass the value from textbox into link to open the new pop up window but it didn't work, can anyone please give me a hand?

    Thanks


    <script>
    function PopupCenter(pageURL, title,w,h) {
    var left = (screen.width/2)-(w/2);
    var top = (screen.height/2)-(h/2);
    var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
    }
    </script>
    <input type="text" value="" id="txtbx" />
    <a onclick="PopupCenter('test2.cfm?box='+document.getElementById('txtbx').value;', 'myPop1',400,400);" href="javascript:void(0);">CLICK TO OPEN POPUP</a>
  2. #2
  3. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,129
    Rep Power
    119
    Try this; it simplifies your code, a little bit:
    Code:
    <script>
    function PopupCenter(pageURL,textField,title,w,h) {
    var left = (screen.width/2)-(w/2);
    var top = (screen.height/2)-(h/2);
    var param = document.getElementById(textField).value;
    var targetWin = window.open(pageURL+param, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
    } 
    </script>
    <input type="text" value="" id="txtbx" />
    <a onclick="PopupCenter('test2.cfm?box=','txtbx','myPop1',400,400)" href="javascript:void(0)">CLICK TO OPEN POPUP</a>
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    21
    Rep Power
    0
    worked, many thanks.

IMN logo majestic logo threadwatch logo seochat tools logo