0

I have a php variable as below:

$starting_package_wedding = $_GET['starting_package_wedding']; which outputs

string '75001-90000' (length=11)

Now I have a javascript in which I will need the the starting_package_wedding variable,

var starting_package_wedding = <?php echo $starting_package_wedding; ?>;
alert(starting_package_wedding);

But the above alert alerts the value after doing the negative operation, ie it alerts a value of 14999 which is equal to 75001 minus 90000 ! How can I get the string in javascript file ?

2 Answers 2

2

Try adding quotes:

var starting_package_wedding = "<?php echo $starting_package_wedding; ?>";
1
  • Wow..Thanks a lot. Working
    – Nitish
    Commented Dec 6, 2013 at 7:14
0

Do the type casting in javascript as above
var name=add the php variable
var starting_package_wedding = Number(name);

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.