sydneyguy
asked on
javascript array not accepting text from php line
have some javascript that is working fine until i add one line
it builds five arrays that hold data from out of a table and just grabs the field and pops it in that array,
if i change the $item->tissue (this is text) to $item->userid (its a number ) it will collect the information
tissue is available to be grabbed, but for some reason it does not like using text in this position cannot see why it will not work
***** the below line does not work
echo (" price_list4[".$curcatnum." ][".$itemn um."] = ".$item->tissue."; ");
***** the below line does work
echo (" price_list4[".$curcatnum." ][".$itemn um."] = ".$item->userid."; ");
see the image for the display of whats in the .$item
var price_list=new Array();
var price_list1=new Array();
var price_list2=new Array();
var price_list3=new Array();
var price_list4=new Array();
// IT ALREADY HAS THE DATA BY THIS POINT
// LOOK AT ITEM
function initprice(){
<?php
$curcatnum = -1;
$itemnum = -1;
$curcat = '';
// THIS IS THE READ POINT
foreach ($this->items as $item) {
$itemnum++;
// IF CURENT CATEGORY DOESNOT= CATEGORY
if ($curcat != $item->category) {
$curcatnum++;
$itemnum = 0;
$curcat = $item->category;
echo ('price_list['.$curcatnum. '] = new Array();'."\n");
echo ('price_list1['.$curcatnum .'] = new Array();'."\n");
echo ('price_list2['.$curcatnum .'] = new Array();'."\n");
echo ('price_list3['.$curcatnum .'] = new Array();'."\n");
echo ('price_list4['.$curcatnum .'] = new Array();'."\n");
// price_list4[0] = price_list1[$curcatnum];
};
echo (" price_list[".$curcatnum."] [".$itemnu m."] = ".$item->cost."; ");
echo (" price_list1[".$curcatnum." ][".$itemn um."] = ".$item->cost1."; ");
echo (" price_list2[".$curcatnum." ][".$itemn um."] = ".$item->cost2."; ");
echo (" price_list3[".$curcatnum." ][".$itemn um."] = ".$item->cost3."; ");
***** the below line does not work
echo (" price_list4[".$curcatnum." ][".$itemn um."] = ".$item->tissue."; ");
//alert(".$item->userid.") ;
$userval = $item->tissue;
}
?>
}
it builds five arrays that hold data from out of a table and just grabs the field and pops it in that array,
if i change the $item->tissue (this is text) to $item->userid (its a number ) it will collect the information
tissue is available to be grabbed, but for some reason it does not like using text in this position cannot see why it will not work
***** the below line does not work
echo (" price_list4[".$curcatnum."
***** the below line does work
echo (" price_list4[".$curcatnum."
see the image for the display of whats in the .$item
var price_list=new Array();
var price_list1=new Array();
var price_list2=new Array();
var price_list3=new Array();
var price_list4=new Array();
// IT ALREADY HAS THE DATA BY THIS POINT
// LOOK AT ITEM
function initprice(){
<?php
$curcatnum = -1;
$itemnum = -1;
$curcat = '';
// THIS IS THE READ POINT
foreach ($this->items as $item) {
$itemnum++;
// IF CURENT CATEGORY DOESNOT= CATEGORY
if ($curcat != $item->category) {
$curcatnum++;
$itemnum = 0;
$curcat = $item->category;
echo ('price_list['.$curcatnum.
echo ('price_list1['.$curcatnum
echo ('price_list2['.$curcatnum
echo ('price_list3['.$curcatnum
echo ('price_list4['.$curcatnum
// price_list4[0] = price_list1[$curcatnum];
};
echo (" price_list[".$curcatnum."]
echo (" price_list1[".$curcatnum."
echo (" price_list2[".$curcatnum."
echo (" price_list3[".$curcatnum."
***** the below line does not work
echo (" price_list4[".$curcatnum."
//alert(".$item->userid.")
$userval = $item->tissue;
}
?>
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
this here does not seem right especially the end
price_list4[3][3] = 466; } where is the rest
price_list[3][0] = 835.00; price_list1[3][0] = 710.00; price_list2[3][0] = 626.00; price_list3[3][0] = 0.00; price_list4[3][0] = 466; price_list[3][1] = 990.00; price_list1[3][1] = 842.00; price_list2[3][1] = 742.00; price_list3[3][1] = 0.00; price_list4[3][1] = 466; price_list[3][2] = 1070.00; price_list1[3][2] = 910.00; price_list2[3][2] = 802.00; price_list3[3][2] = 0.00; price_list4[3][2] = 466; price_list[3][3] = 1030.00; price_list1[3][3] = 876.00; price_list2[3][3] = 772.00; price_list3[3][3] = 0.00; price_list4[3][3] = 466; }
price_list4[3][3] = 466; } where is the rest
price_list[3][0] = 835.00; price_list1[3][0] = 710.00; price_list2[3][0] = 626.00; price_list3[3][0] = 0.00; price_list4[3][0] = 466; price_list[3][1] = 990.00; price_list1[3][1] = 842.00; price_list2[3][1] = 742.00; price_list3[3][1] = 0.00; price_list4[3][1] = 466; price_list[3][2] = 1070.00; price_list1[3][2] = 910.00; price_list2[3][2] = 802.00; price_list3[3][2] = 0.00; price_list4[3][2] = 466; price_list[3][3] = 1030.00; price_list1[3][3] = 876.00; price_list2[3][3] = 772.00; price_list3[3][3] = 0.00; price_list4[3][3] = 466; }
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I think Chris is right. In...
price_list4[0][0] = skin;
'skin' will be considered the name of a variable, not a 'value' because it is not quoted. And of course, there is no such variable.
price_list4[0][0] = skin;
'skin' will be considered the name of a variable, not a 'value' because it is not quoted. And of course, there is no such variable.
ASKER
it is javascript with php wrapped around it
thanks for the input went through the code and came up with the line below that works fine
echo (" price_list4[".$curcatnum." ][".$itemn um."] = '".$item->tissue."'; ");
thanks for all the help its now up and running thanks every one
thanks for the input went through the code and came up with the line below that works fine
echo (" price_list4[".$curcatnum."
thanks for all the help its now up and running thanks every one
Thanks for the points and thanks for using EE, ~Ray
@sydneyguy
When you say you 'went through the code and came up with the following' - I think what you you actually meant to say was 'I copied Chris's code exactly and it worked!!'.
Just for future reference, here on EE, it's considered good practice to accept the answer that actually answers your question...call me old fashioned but I'm funny like that!!
When you say you 'went through the code and came up with the following' - I think what you you actually meant to say was 'I copied Chris's code exactly and it worked!!'.
Just for future reference, here on EE, it's considered good practice to accept the answer that actually answers your question...call me old fashioned but I'm funny like that!!
ASKER
put the line in and the number increments and but no total is acted upon.
i also cannot see what is wrong, when i run the de bugger over it in php i can see the values and there there , change it to a number from the items, and it works change it back to text value and it stops. no errors are displayed
looking at the page it looks ok, great idea a must say. good thinking
below is a drop out around the array
Open in new window