0

I'm trying to concatenate a link in a javascript function with a php variable. But whatever a try to write after ""+ doesn't get displayed and the whole program stops working. The variable is defined in a different page. I tried REQUEST to access to it, but it's not working.

function popupEvent(){
    $('#btnClose').unbind("click"); 
    $('#btnClose').click(function(){
    window.location = SITEURL+"cart/rollPdf/?POrderNo="+implode(',', $orderIDArr); 
  window.open(ord,'winname','directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=350');             

        return false
    });
}
Hans Solo
  • 55
  • 3
  • 16
  • That are two different languages, and two of such kind that you can not mix them. See http://stackoverflow.com/q/168214/367456 on how to deal with that. And just another hint: We have tons of material in this Q&A site already about that topic, I bet with a little searching and browsing you'll spot something to read in your very fashion and mood of the day. – hakre May 19 '17 at 07:48

1 Answers1

0

Whenever you want to use PHP variable into JS, you need echo it. Ex, <?php echo implode(',', $orderIDArr);?>

In your code try Like this,

function popupEvent(){
    $('#btnClose').unbind("click"); 
    $('#btnClose').click(function(){
    window.location = SITEURL+"cart/rollPdf/?POrderNo=<?php echo implode(',', $orderIDArr);?>"; // Changed here
  window.open(ord,'winname','directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=350');             

        return false
    });
}

Hope this will help you to solve your problem...

EDIT:

function popupEvent(){
    $('#btnClose').unbind("click"); 
    $('#btnClose').click(function(){
    ord = SITEURL+"cart/rollPdf/?POrderNo=<?php echo implode(',', $orderIDArr);?>"; // Changed here
  window.open(ord,'winname','directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=350');             

        return false
    });
}
Naga
  • 2,190
  • 3
  • 16
  • 21