I’m noob, but with pleasure I will take the wand if you help me find the answer;)
I have a list of categories in the $ cat_array array. I want to create a drop-down menu so that when one of the parameters is selected, another variable is passed to the function.
This is what I have so far: In the main file (index.php) I call the function:
makechoice($cat_array);
This applies to this function, which is located in the included file:
function makechoice($cat_array) {
$dbz = new db();
$sim = new simple();
echo '<div class="choose-section">';
echo '<select class="selbox" onchange="categoryAjaxData(\'facebook\',\'/includes/fancount.php\',this.value);">';
foreach($cat_array as $cat) {
echo('<option value="'.$cat[0].'">'.$cat[1].'</option>');
}
echo '</select>';
echo 'Choose a section';
echo '</div>';
echo '<div id="facebook"><div class="facebook-midcut">',showfans($djnames, $djids, $djurl),'</div><div class="l-botcut"></div></div>';
}
In include / fancount.php, I basically have many different variables that I want to pass through the showfans function.
eg. $ barnames, $ barids, $ barurl and $ restaurantname, $ restaurantids, $ restauranturl
The showfans function uses these variables to display some data about them.
This is my javascript code:
function categoryAjaxData(div,str,value)
{
var url = str+'?catid='+value;
ajaxData(div,url);
}
function ajaxData(div,str)
{
xmlHttp=GetXmlHttpObject();
document.getElementById(div).innerHTML='<center><img src="images/loader.gif"></center>';
if(xmlHttp==null)
{
alert("Browser does not support HTTP Request")
return
}
var url = str;
xmlHttp.onreadystatechange = function(){ DescriptionstateChanged(div); };
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function DescriptionstateChanged(div)
{
if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById(div).innerHTML=xmlHttp.responseText;
}
}
:
facebook div , , , , select, showfans().
.
, "" :
echo '<div id="facebook"><div class="facebook-midcut">',showfans($barnames, $barids, $barurl),'</div><div class="l-botcut"></div></div>';
, "" :
echo '<div id="facebook"><div class="facebook-midcut">',showfans($restaurantnames, $restaurantids, $restauranturl),'</div><div class="l-botcut"></div></div>';
, ! :)
UPDATE:
fancount.php, - !
, varlue showfans(), , :
echo '', showfans ($ restaurantnames, $restaurantids, $restauranturl), '';