2013-10-19 79 views
0

我目前正在爲BlackBerry 10開發eBay應用程序,並遇到了問題。問題是,我想要一個下拉菜單(這樣用戶可以選擇他們想要訪問哪個eBay國家),但我不知道如何讓屏幕底部的按鈕進入正確的頁面在下拉菜單中選擇了一個選項。如何使用HTML中的下拉菜單來更改元素?

http://i1078.photobucket.com/albums/w483/tobster619/Blackberry%2010/help_zps923bcc21.png

這裏是一個細分版本的代碼,可以在附加圖像中可以看出:

<script type="text/javascript"> 
//verify the welcome screen 
function verifywelcome(){ 
if (document.getElementById('checkbox').get... == true) { 
alert('checkbox is checked'); 
//set the localstorage item 
localStorage.welcome = "true" ; 
} else if (document.getElementById('checkbox').get... == false) { 
alert('checkbox is not checked'); 
//set the localstorage item 
localStorage.welcome = "false"; 
} 
} 
//if you want to remove the localStorage key to redisplay the welcome screen again. use: localStorage.removeItem('welcome'); 
function welcome() { 
//check if welcome exists, if not: create it 
if (localStorage.welcome == null) { localStorage.welcome = "true" }; 
if (localStorage.getItem('welcome') == "true") /* if it is true: */ { 
bb.pushScreen('welcome.html', 'welcome'); 
} 
else if (localStorage.getItem('welcome') == "false") { 
bb.pushScreen('menu.html', 'menu'); 
} 
} 

//verify the welcome screen 
function verifywelcome2(){ 
if (document.getElementById('checkbox').get... == true) { 
alert('checkbox is checked'); 
//set the localstorage item 
localStorage.welcome = "true" ; 
} else if (document.getElementById('checkbox').get... == false) { 
alert('checkbox is not checked'); 
//set the localstorage item 
localStorage.welcome = "false"; 
} 
} 


//if you want to remove the localStorage key to redisplay the welcome screen again. use: localStorage.removeItem('welcome'); 
function welcome() { 
//check if welcome exists, if not: create it 
if (localStorage.welcome == null) { localStorage.welcome = "true" }; 
if (localStorage.getItem('welcome') == "true") /* if it is true: */ { 
bb.pushScreen('welcome.html', 'welcome'); 
} 
else if (localStorage.getItem('welcome') == "false") { 
bb.pushScreen('menu2.html', 'menu2'); 
} 
} 
function onLoadFunctions() { 
// Register the app. Make sure you get a unique UUID! 
blackberry.event.addEventListener('ona... function (accessible, status) { 
if (status === 'unregistered') { 
blackberry.bbm.platform.register({ 
uuid: 'b1e606e8-66e5-41db-a932-6ad42f2aa59c' 
}); 
} else if (status === 'allowed') { 
bbm.registered = accessible; 
} 
}, false) 
} 
</script> 

<select id="countryselector"> 
<option value="eBay UK" selected="true" onchange="verifywelcome();bb.pushScreen(... 'Menu');onLoadFunctions();">eBay UK</option> 
<option value="eBay US" "verifywelcome2();bb.pushScreen('menu2.h... 'Menu2');onLoadFunctions();">eBay US</option> 
<option value="eBay CA">eBay CA</option> 
</select> 
<table> 
<tr> 
<td class="cell" style="margin-top:13px;">Show this page on launch</td> 
<td class="cell" ><input id="checkbox" type="checkbox" checked="true" value="one"/> </td> 
</tr> 
</table> 
<!--BOTTOM PAGE MENU BAR --> 
<div data-bb-type="action-bar"> 
<div data-bb-type="action" data-bb-style="button" data-bb-img="IMG/ic_next.png" onclick="verifywelcome();bb.pushScreen('... 'Menu');onLoadFunctions();">The Native eBay Experience Awaits...</div> 
</div> 

所以,當用戶點擊該按鈕(代碼的最後一部分我剛剛向你展示了),它會把他們帶到eBay UK(menu.html),我的問題是:如果用戶選擇eBay US(menu2.html),當他們點擊它將他們帶到menu2.html(eBay US)而不是menu.html(eBay UK),同時仍然允許不同的onclick功能工作(「verifywelcome(); verifywelcome2(); nLoadFunctions();「)?

在此先感謝!

回答

0

您可以在select級別(而不是option級別)定義onchange事件,並將選項的值設置爲它們對應的各個頁面。那麼對於onchange處理程序將按鈕的click處理程序設置類似document.location = this.value(其中thiscountryselector元素。

我從來沒有在黑莓DOM編程,所以我不能寫任何代碼。但這可能給你一個想法。

相關問題