Here is the safest way to do this:
<?php
$typeid = 65;
$subledgerid = 'subledger'.$typeid;
$loadledger = 'loadledgers';
?>
<script type="text/javascript">
view_subledger.apply(window, <?php print json_encode(array(
$typeid,
$subledgerid,
$loadledger
)); ?>);
</script>
Which generates following code:
<script type="text/javascript">
view_subledger.apply(window, [65,"subledger65","loadledgers"]);
</script>
json_encode() will ensure that variables are escaped properly and with .apply() method you can pass parameter array to JS function.
Another suggested version:
<?php
$typeid = 65;
$subledgerid = 'subledger'.$typeid;
$loadledger = 'loadledgers';
$param_str = implode(', ', array_map('json_encode', array(
$typeid,
$subledgerid,
$loadledger
)));
?>
<script type="text/javascript">
view_subledger(<?php print $param_str; ?>);
</script>
Generates following:
<script type="text/javascript">
view_subledger(65, "subledger65", "loadledgers");
</script>
$subledgerid;
numeric? Than you are missing the prefixsubledger
. Anyhow, post us the HTML output that you have when you are doing stuf with PHP.$subledgerid
is alphanumeric....