Although being a web application developer, I am very weak with Javascript, the thing that does much more than client side validations. I never really liked to code in Javascript. All I used to do was copy the validation source code from the net & paste it in my application.
Today, I was stuck with a very minor problem with javascript. All I had to do was convert a PHP array into a Javascript one, so that I can pass it as a parameter to a Javascript function.
Well, the problem was solved but it took a lot of efforts for me(I am still a Javascript rookie).
Following is the code to be written in PHP file:
<script language="javascript">
var jsArray = new Array();
< ?php
foreach($phpArray as $key => $value) {
echo "jsArray ['".$key ."']='".$value."';\n";
}
?>
</script>

No comments yet
Comments feed for this article