I am trying to create a javascript object using javascript variables but won't work. However it appears to work if i use asp variable! I have 2 code snipnets: data = "Contract1":["S1234", "62,615.266","7-Dec-2007"], "Contract1":["S1234", "62,615.266","7-Dec-2007"] if 'data' is an asp variable <script> var myData = {<%=data%>}; alert ('myData = ' + myData[0][1]); </script> works fine However if 'data' is javascript variable <script> var myData = {data}; alert ('myData = ' + myData[0][1]); </script> doesn't work. What could be wrong somebody help!
In problem statement above, variable 'data' holds the property-value pairs which are then used to create a javascript object. How else would i define it in javascript. Please help
In problem statement above, variable 'data' holds the property-value pairs which are then used to create a javascript object. How else would i define it in javascript. Please help
You define a multidimension array in javascript like: yourArray = new Array(); yourArray[0] = new Array(); yourArray[0][0] = "blah"; Code (markup): If i remember right.
Allow me to re-phrase my query, I need to construct propert-value pair object in javascript using object literals. The general format of the object literal is defined as: var obj = {string:array}; If the propert-value pair is constructed in asp so that var obj = {<%=property-valuepairstring%>} ; works fine, however if property-valuepairstring is a javascript variable i.e. var obj = {property-valuepairstring}; i encounter object expected error. Please shed some light in the dilemma i find myself.