2

I have this code here:

<script type="text/javascript">
    var batchidstring = <?php echo $batchId; ?>;
</script>

$batchId value is 1,2,3,4,5

They were seperated with comma.

I get this error:

Uncaught SyntaxError: Unexpected number

The error where in code var batchidstring = 1,2,3,4,5;

Can anyone show me or correct the codes?

A.A Noman
  • 5,244
  • 9
  • 24
  • 46
Muhammed Fayaz
  • 45
  • 1
  • 14

1 Answers1

0

if you need string you must wrap the var with proper quote

var batchidstring = <?php echo "'" . $batchId . "'"; ?>;
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107