Как заставить элемент меняться с помощью раскрывающегося списка в HTML?

0

В настоящее время я разрабатываю приложение eBay для BlackBerry 10 и сталкиваюсь с проблемой. Проблема в том, что я хотел бы иметь раскрывающееся меню (так что пользователь может выбрать, какую страну eBay они хотят получить), но я не знаю, как получить кнопку в нижней части экрана, чтобы перейти на правильную страницу, когда в выпадающем списке была выбрана опция.

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(); onLoadFunctions(); ")?

Заранее спасибо!

Теги:
getelementbyid

1 ответ

0

Вы можете определить событие onchange на уровне select (а не на уровне option) и сделать значения параметров соответствующими страницами, на которые они соответствуют. Затем обработчик для onchange установит обработчик нажатия click на что-то вроде document.location = this.value (где this элемент countryselector.

Я никогда не программировал в Blackberry DOM, поэтому я не могу написать код. Но, возможно, это дает вам представление.

Ещё вопросы

Сообщество Overcoder
Наверх
Меню