Easyrider43
asked on
javascript not passing variable
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"><inpu t type="radio" name="color" value="#DD597D" onClick="color_changer(thi s.value,\' center_inf o\',\'4001 \');"/>Red';
echo '<div class="color_option"><inpu t type="radio" name="color" value="#0000FF" onClick="color_changer(thi s.value,\' center_inf o\',\'4001 \');"/>Blue';
echo '<div class="color_option"><inpu t type="radio" name="color" value="#00FF00" onClick="color_changer(thi s.value,\' center_inf o\',\'4001 \');"/>Lime';
echo '</form>';
}
function color_changer(color, divname, userid)
{
document.getElementById(di vname).sty le.backgro und=color;
connect_ajax()
xmlhttp.onreadystatechange =function( )
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("r ight_side" ).innerHTM L=xmlhttp. responseTe xt;
/*theme(userid);*/
return;
}
}
xmlhttp.open("GET","../fun ctions/acc ount_setti ngs.php?id=changetheme&do="+userid +"&co="+co lor,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) ;
}
if ($id == 'theme')
{
echo '<form>';
echo '<div class="color_option"><inpu
echo '<div class="color_option"><inpu
echo '<div class="color_option"><inpu
echo '</form>';
}
function color_changer(color, divname, userid)
{
document.getElementById(di
connect_ajax()
xmlhttp.onreadystatechange
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("r
/*theme(userid);*/
return;
}
}
xmlhttp.open("GET","../fun
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
$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)
}
ignore my first post;are you getting value here?
function color_changer(color, divname, userid)
{
alert(color)
document.getElementById(di vname).sty le.backgro und=color;
function color_changer(color, divname, userid)
{
alert(color)
document.getElementById(di
ASKER
yup it alerts me the color but for some reason in the xmlhttp.open string its not reading that "color" variable
ASKER
I get the userid passed but not the color, am i missing some quote or something????
quotes are correct.
xmlhttp.open("GET","../fun ctions/acc ount_setti ngs.php?id =changethe me&do="+us erid+"&co= "+color);
xmlhttp.open("GET","../fun
ASKER
they why does it come up as null?
In the PHP, are you doing $id = $_GET['id']; first? If not, then $id is null or non-existent.
ASKER
Yea its declared first, yet it show's up empty on the $qry script
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
that was it, apparently you cant pass a "#" inside a link. Thanks for pointing that out
Glad it worked
Meeran03
Meeran03
xmlhttp.send();