Jump to content

Data From Js Array


crush123

Recommended Posts

I have a form on a php product detail page which allows a customer to choose size and color options.the combination of size and color determines the product pricewhat i would like to do, is display the price on the screen, as an on change event, after the color is chosen.in order to do this, i think the best (only) appropach , would be to create an array in php using a recordset as a data source, and then from this php array, create a javascript array, which i can then interrogate using the values from the size and color list boxes.so far, i have tried creating 2 types of array, simple and multidimensional.with the simple php array, i can create a js array which holds the sizeid, colorid and price in each key...js_array[0] = (2, 1, 8.00);js_array[1] = (2, 2, 14.00);js_array[2] = (4, 1, 7.00);js_array[3] = (4, 4, 11.00); i don't know if this is the array structure i need, but what i want to do is select the correct price, having retrieved the color and size id'si can retrieve the values from the size and color select lists ok, but i dont know how to get the price information from the array.i also tried creating a multdimensional array, which in php looks like this...Array( [0] => Array ( [sizeid] => 1 [colourid] => 1 [price] => 10.00 ) [1] => Array ( [sizeid] => 1 [colourid] => 4 [price] => 13.00 ) [2] => Array ( [sizeid] => 3 [colourid] => 1 [price] => 14.00 ) [3] => Array ( [sizeid] => 3 [colourid] => 3 [price] => 18.00 ))but i dont know how to convert this into a js arraygrateful for some advice on if this is the best approach, which array strucure to use, and how retrieve the value i need.(also how to convert multidimensionalphp array into js array)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...