November 25th, 2013, 04:37 PM
-
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>
November 25th, 2013, 08:20 PM
-
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>
November 26th, 2013, 07:33 AM
-