I am passing vlues to javasript function from PHP in following manner:
<select onChange="display_databody(<?=$manufacturers_id?>,<?=$modelID?>,this.value,<?=**$month_year**?>);">
Here $month_year is a string obtained from MySQL.
When javascript function is getting this value it is getting something like -8 or -13.
I have tried json_encode() but it is also not working.
I had a brainwave and guessed that
$month_yearis a string like1-12for January 2012. This would result in your HTML becoming something likeand Javascript will evaluate that value (as
-11here) when it executes the function.Wrap your string values in single quotes. You may need to do that with the first two as well if they aren’t entirely numeric. Line split here for clarity: you will probably join it back together.