我再次嘗試提問我的問題。我希望這一次足夠清楚。將客戶端JavaScript變量傳遞給服務器端php
這裏是我的腳本的現場演示: http://www.virusgaming.net/test/
這是代碼:
<? // I set the starting percentage to 0%.
$something = 0; ?>
<!-- jsProgressBarHandler prerequisites : prototype.js -->
<script type="text/javascript" src="js/prototype/prototype.js"></script>
<!-- jsProgressBarHandler core -->
<script type="text/javascript" src="js/bramus/jsProgressBarHandler.js"></script>
<span style="color:#006600;font-weight:bold;">Multi Color Bar</span> <br/>
<span id="element6">Loading...</span>
<span class="extra"><a href="#" onclick="manualPB2.setPercentage('0', true);return false;"><img src="images/icons/empty.gif" alt="" title="" onmouseout="$('Text6').innerHTML ='« Select Options'" onmouseover="$('Text6').innerHTML ='Empty Bar'"/></a></span>
<span class="options"><a href="#" onclick="manualPB2.setPercentage('+10');return false;"><img src="images/icons/add.gif" alt="" title="" onmouseout="$('Text6').innerHTML ='« Select Options'" onmouseover="$('Text6').innerHTML ='Add 10%'"/></a></span>
<span class="options"><a href="#" onclick="manualPB2.setPercentage('-5');return false;"><img src="images/icons/minus.gif" alt="" title="" onmouseout="$('Text6').innerHTML ='« Select Options'" onmouseover="$('Text6').innerHTML ='Minus 5%'" /></a></span>
<span class="options"><a href="#" onclick="manualPB2.setPercentage('30');return false;"><img src="images/icons/set.gif" alt="" title="" onmouseout="$('Text6').innerHTML ='« Select Options'" onmouseover="$('Text6').innerHTML ='Set 30%'"/></a></span>
<span class="options"><a href="#" onclick="manualPB2.setPercentage('98'); manualPB2.setPercentage('30'); return false;"><img src="images/icons/fill.gif" alt="" title="" onmouseout="$('Text6').innerHTML ='« Select Options'" onmouseover="$('Text6').innerHTML ='Fill 98%, and then 30%'" /></a></span>
<span class="getOption"><a href="#" onclick="alert(manualPB2.getPercentage());return false;"><img src="images/icons/get.gif" alt="" title="" onmouseout="$('Text6').innerHTML ='« Select Options'" onmouseover="$('Text6').innerHTML ='Get Current %'"/></a></span>
<span id="Text6" style="font-weight:bold">« Select Options</span>
<script type="text/javascript">
document.observe('dom:loaded', function() {
manualPB2 = new JS_BRAMUS.jsProgressBar(
$('element6'),
<? echo $something; ?>,
{
barImage : Array(
'images/bramus/percentImage_back4.png',
'images/bramus/percentImage_back3.png',
'images/bramus/percentImage_back2.png',
'images/bramus/percentImage_back1.png'
),
onTick : function(pbObj) {
switch(pbObj.getPercentage()) {
case 70:
alert('we are at 70%');
break;
case 100:
alert('we are at 100%');
break;
}
return true;
}
}
);
}, false);
</script>
我想通過客戶端JavaScript百分比服務器端PHP變量。我用GET和POST javascript(隱藏的字段,表單,錨點,onclick事件等)做了數十次嘗試,但沒有成功。基本上與的onclick =「警報(manualPB2.getPercentage());功能我跺電流百分比警報可以編輯該警報,使其後/獲取變量到PHP
簡而言之 - >使用隱藏的輸入字段創建隱藏表單...將該值分配給該輸入的值,然後提交該表單。或者只是使用Ajax。 – Wh1T3h4Ck5 2012-03-16 15:43:31
當然。使用ajax(原型應該有大量關於如何完成你想要的東西的文檔)。你想跟蹤的進展是什麼? – Jason 2012-03-16 15:44:06