0

I'm trying to show some info in a pop-up window usig a window.open.. but when I click nothing happens.

This is the function that opens a new window.

function goNewWin(sell_code){
// Set height and width
var NewWinHeight=1000;
var NewWinWidth=1000;
// Place the window
var NewWinPutX=10;
var NewWinPutY=10;
//Get what is below onto one line
TheNewWin =window.open("renovations_history.php?sell_code=" + sell_code,
'Renovaciones','fullscreen=yes,toolbar=no,location=no,status=no,menubar=no,scrollbars=no');
//Get what is above onto one line
TheNewWin.resizeTo(NewWinHeight,NewWinWidth);
TheNewWin.moveTo(NewWinPutX,NewWinPutY);
}
</script>

Here's the HTML, with some PHP.

<form>
 <input type="button" value="Renovaciones" onClick="goNewWin(<?php echo $row['sell_code']; ?>)">
</form>

Nor it works with:

<a href="javascript:goNewWin(<?php echo $row['sell_code']; ?>)">Renovaciones</a>

It's 2:22 am and I can think straight, please help.

asked Nov 28, 2014 at 6:57
0

2 Answers 2

1

You need to add single quotes to the JavaScript function call:

<?php
$sell_code = $row['sell_code'];
?>
<input type="button" value="Renovaciones" onClick="goNewWin('<?php echo $sell_code]; ?>')">

Without it, Javascript will consider your $row['sell_code'] as a javascript keyword.

You need to pass it as a string (function parameter).

Reference

answered Nov 28, 2014 at 7:02
Sign up to request clarification or add additional context in comments.

Comments

0

if $row['sell_code'] is a string the you can use

$sellCode = $row['sell_code'];
onClick="goNewWin('<?php echo $sellCode; ?>')">
answered Nov 28, 2014 at 6:59

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.