troubleshooting Question

javascript array not accepting text from php line

Avatar of sydneyguy
sydneyguyFlag for Australia asked on
JavaScriptPHPScripting Languages
9 Comments3 Solutions446 ViewsLast Modified:
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."][".$itemnum."] = ".$item->tissue."; ");
***** the below line does work
echo ("      price_list4[".$curcatnum."][".$itemnum."] = ".$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."][".$itemnum."] = ".$item->cost."; ");
            echo ("      price_list1[".$curcatnum."][".$itemnum."] = ".$item->cost1."; ");
            echo ("      price_list2[".$curcatnum."][".$itemnum."] = ".$item->cost2."; ");
            echo ("      price_list3[".$curcatnum."][".$itemnum."] = ".$item->cost3."; ");

***** the below line does not work            
            echo ("      price_list4[".$curcatnum."][".$itemnum."] = ".$item->tissue."; ");
            
      //alert(".$item->userid.");

            $userval = $item->tissue;
      }
?>
}


javascriptarray
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 3 Answers and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros