0

I'm not sure if this is possible, but I'm trying to take the value of $css_color and set it as the hex value in the div. Also with the $x and $y values.

Essentially, I'm attempting to grab the $x$y info and the hex code value from an image and matching it to an array of color values I have in formatted_colors.js then rebuilding the "image" as divs with the background color as testing.

Example of my formatted_colors.js array var colors = []; colors["000000"] = "black"; colors["100000"] = "black";

Here is a snippet:

<script type="text/javascript" src="jquery-1.6.2.js"></script>
<script src="formatted_colors.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">

//iterate through pixels and match rounded color to array in formatted_colors.js

<div class="rounded_color" hex="<?php $css_color ?>" xy="<?php $x.$y ?>"</div>
<div id="<?php $x.$y ?>"></div>

$(document).ready(function() {

    $(".rounded_color").each(function(){
            var google_color = getColor($(this).attr("hex"));
            $('#'+$(this).attr("id")).html(google_color);
            $('#'+$(this).attr("id")).css('background-color:', google_color);
    })


// get name of color function from formatted_colors.js

function getColor(target_color){
    if (colors[target_color] == undefined) { // not found
      return "no match";
    } else {
      return colors[target_color];
    }
  } // end getColor function


)} // end ready function

</script>

And here is my entire code: http://pastebin.com/A4tMsn2C

dynamic
  • 46,985
  • 55
  • 154
  • 231
Richard
  • 826
  • 7
  • 23
  • 41

1 Answers1

2

Try <?php echo $x.$y ?> instead (and similar for your other blocks). Or, if you've got shorttags enabled <?= $x . $y ?>. Your version is simply doing a concatentation and throwing out the results. You need to echo out the results of whatever you're doing inside the PHP block.

Marc B
  • 356,200
  • 43
  • 426
  • 500
  • is the safer bet. Short tags are ill advised.. http://stackoverflow.com/questions/200640/are-php-short-tags-acceptable-to-use – rlemon Aug 16 '11 at 16:47