We help IT Professionals succeed at work.
Get Started

javascript not passing variable

Easyrider43
Easyrider43 asked
on
315 Views
Last Modified: 2012-05-12
For some reason when I pass the "color" variable php cant pick it up- it just comes up blank. can someone please look at my code and see if im doing something wrong.. thanks guys

if ($id == 'theme')
      {
      echo '<form>';
      echo '<div class="color_option"><input type="radio" name="color" value="#DD597D" onClick="color_changer(this.value,\'center_info\',\'4001\');"/>Red';
      echo '<div class="color_option"><input type="radio" name="color" value="#0000FF" onClick="color_changer(this.value,\'center_info\',\'4001\');"/>Blue';
      echo '<div class="color_option"><input type="radio" name="color" value="#00FF00" onClick="color_changer(this.value,\'center_info\',\'4001\');"/>Lime';
      echo '</form>';
      }

function color_changer(color, divname, userid)
{
document.getElementById(divname).style.background=color;
connect_ajax()
xmlhttp.onreadystatechange=function()
      {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
            {
            document.getElementById("right_side").innerHTML=xmlhttp.responseText;
            /*theme(userid);*/
            return;
            }
      }
xmlhttp.open("GET","../functions/account_settings.php?id=changetheme&do="+userid+"&co="+color,true);
xmlhttp.send();
}



if ($id == 'changetheme')
      {
      
      $theme = $_GET['co'];
      include ('../config/config.php');
      mysql_pconnect ($host, $user, $pass) or die ('Unable To Connect to Database!');
      mysql_select_db('providers') or die ('Unable To Select Database');
      $qry = "UPDATE contractors SET theme ='$theme' WHERE id = '$userid' LIMIT 1";
      echo $qry;
      echo $theme;      
      //$result = mysql_query($qry) or die ('Error in query: $qry. ' . mysql_error());
      mysql_free_result($result);
      }
Comment
Watch Question
Consultant
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 11 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE