FIXED;這是在fancount.php文件中添加另一個include的情況!如何將<select>下拉列表的值傳遞到使用javascript的另一個文件中的功能
初始代碼:
<div class="l-title">
<div class="t-left"></div>
<div class="t-mid">Popularity Update</div>
<div class="t-right"></div></div>
<?php makechoice($cat_array); ?>
功能代碼:
function makechoice($cat_array) {
global $djnames;
global $djids;
global $djurl;
$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>';
}
代碼從fancount.php
<?php
include_once("../_inc/global.php");
include_once("../_inc/dbmysql.php");
include_once("../_inc/simple.php");
$dbz = new db();
$sim = new simple();
switch ($_GET['catid']) {
case 1:
echo '<div id="facebook"><div class="facebook-midcut">',showfans($barnames, $barids, $barurl),'</div><div class="l-botcut"></div></div>';
break;
case 2:
echo '<div id="facebook"><div class="facebook-midcut">',showfans($beachrestaurantnames, $beachrestaurantids, $beachrestauranturl),'</div><div class="l-botcut"></div></div>';
break;
case 3:
echo '<div id="facebook"><div class="facebook-midcut">',showfans($clubnames, $clubids, $cluburl),'</div><div class="l-botcut"></div></div>';
break;
case 4:
echo '<div id="facebook"><div class="facebook-midcut">',showfans($clubnightnames, $clubnightids, $clubnighturl),'</div><div class="l-botcut"></div></div>';
break;
case 5:
echo '<div id="facebook"><div class="facebook-midcut">',showfans($djnames, $djids, $djurl),'</div><div class="l-botcut"></div></div>';
break;
case 6:
echo '<div id="facebook"><div class="facebook-midcut">',showfans($hotelnames, $hotelids, $hotelurl),'</div><div class="l-botcut"></div></div>';
break;
case 7:
echo '<div id="facebook"><div class="facebook-midcut">',showfans($liveshownames, $liveshowids, $liveshowurl),'</div><div class="l-botcut"></div></div>';
break;
case 8:
echo '<div id="facebook"><div class="facebook-midcut">',showfans($restaurantnames, $restaurantids, $restauranturl),'</div><div class="l-botcut"></div></div>';
break;
case 9:
echo '<div id="facebook"><div class="facebook-midcut">',showfans($sunsetnames, $sunsetids, $sunseturl),'</div><div class="l-botcut"></div></div>';
break;
case 10:
echo '<div id="facebook"><div class="facebook-midcut">',showfans($villanames, $villaids, $villaurl),'</div><div class="l-botcut"></div></div>';
break;
default:
echo '<div id="facebook"><div class="facebook-midcut">',showfans($djnames, $djids, $djurl),'</div><div class="l-botcut"></div></div>';
}
?>
Ajax代碼:
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;
}
}
我覺得它在我的水域中,我幾乎在那裏......任何人都可以提供解決方案...... MarioVW,知識的字體先生 - 你可以給我頭上的啓發嗎?
看起來像一個跟進闕stion from this -unanswered- one:[更改div的內容使用下拉,javascript和PHP](http://stackoverflow.com/questions/4888910/changing-the-contents-of-a-div-using- a-dropdown-javascript-and-php)...我相信你應該在同一個問題中跟進,而不是問一個新的問題... – MarioVW 2011-02-04 01:00:14
我不想從最後一個問題中刪除代碼,因爲我認爲這個問題中的代碼有很大不同。 – 2011-02-04 01:02:15
只要確保將這兩個問題交叉連接以備將來參考,並且一旦問題解決後也接受兩個問題的答案。 – MarioVW 2011-02-04 01:16:05