samedi 3 janvier 2015

Translator Trouble


This is how the webpage looks like http://ift.tt/1ApZZYQ


I've created an onclick function for the 'generate romaji' button that checks if 'vowels' or 'all columns' is checked, and then displays random romaji characters in the div right under the 'generate romaji' button.


The problem is, it isn't working and i'm not sure why.



var vowel = document.getElementById("vowels");
var allhiragana = document.getElementById("all");
//^^vars are for the 2 checkboxes//
var genDiv = document.getElementById("romaji");
var showDiv = document.getElementById("hiragana");
var fullromaji = [];
var fullhiragana = [];
//first random factor//
var r = Math.floor(Math.random() * fullRomaji.length);
//second random factor//
var h = Math.floor(Math.random() * fullRomaji.length);
//button functions//
var genromaji = function() {
if(vowel.prop('checked')){
fullromaji = ["a",'i','u','e','o'];
fullhiragana = ['あ','い','う','え','お'];
genDiv.innerHTML = fullromaji[r];
showDiv.innerHTML = fullhiragana[r];
showDiv.text().hide();
}
if(allhiragana.prop('checked')) {
fullromaji = ["ka","ki","ku""ke","ko","sa",'shi','su','se','so',
"ta","chi","tsu","te","to","na","ni","nu","ne","no","ha","hi","fu","he","ho","ma","mi",
"mu","me","mo","ya","yu","yo","ra","ri","ru","re","ro",
"wa","wo"];
fullhiragana = ['あ','い','う','え','お','か','き','く','け','こ','さ','し','す','せ','そ',
'た','ち' 'つ','て','と','な','に','ぬ','ね','の','は','ひ','ふ','へ','ほ','ま','み','む','め','も',
'や','ゆ','よ','ら','り','る''れ','ろ','わ','ゐ','ゑ','を'];
genDiv.innerHTML = fullromaji[h];
showDiv.innerHTML = fullhiragana[h];
showDiv.text().hide();
}
else {
alert("please check one box before generating Romaji");
};


The 'genDiv' is the div that is under the 'generate romaji' button, and its inner text should be a random string from the 'fullromaji' array, and the showDiv is the div under the 'show hiragana' button that shows the corresponding hiragana from the 'fullhiragana' array.


I'm not sure if the problem is the code itself, or maybe its the way I linked it in the html, which, for the sake of reading this question, is shorted but still visible in this printscreen


http://ift.tt/145STwb





Aucun commentaire:

Enregistrer un commentaire