{"id":26847,"date":"2016-12-11T03:01:28","date_gmt":"2016-12-10T17:01:28","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=26847"},"modified":"2016-12-11T07:11:17","modified_gmt":"2016-12-10T21:11:17","slug":"htmljavascript-jumbled-sentences-game-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/htmljavascript-jumbled-sentences-game-tutorial\/","title":{"rendered":"HTML\/Javascript Jumbled Sentences Game Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/jumbled_sentences.html\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"HTML\/Javascript Jumbled Sentences Game Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/jumbled_sentences.jpg\" title=\"HTML\/Javascript Jumbled Sentences Game Tutorial\"  \/><\/a><p class=\"wp-caption-text\">HTML\/Javascript Jumbled Sentences Game Tutorial<\/p><\/div>\n<p>We have an <a target=_blank title='ESL information from Wikipedia ... thanks' href='http:\/\/en.wikipedia.org\/wiki\/English_as_a_second_or_foreign_language'>ESL<\/a> (or &#8220;English as a Second or Foreign Language&#8221;) Jumbled Sentence construction game today that builds on the basic (game) structure of <a title='HTML\/Javascript Homophones Game Tutorial' href='#hjhgt'>HTML\/Javascript Homophones Game Tutorial<\/a> as shown below.<\/p>\n<p>Doing this web application, though, taught me, yet again, about how incredibly useful is the HTML <a target=_blank title='HTML select tag information from w3schools' href='http:\/\/www.w3schools.com\/tags\/tag_select.asp'>select<\/a> (dropdown) element for efficient use of data.<\/p>\n<p>Consider one of the &#8220;word for word&#8221; dropdowns we construct during the game (and they all have a similar look) &#8230;<\/p>\n<p><code><br \/>\n&lt;select id=\"s6\" style=\"font-size:24px;background-color:pink;\" onchange=\"scoreit(this);\"&gt;&lt;option value=\"<font color=blue><i><\/i><\/font>\"&gt;<font color=magenta><i>beans<\/i><\/font>&lt;\/option&gt;&lt;option title=\"<font color=purple><i>beans<\/i><\/font>\" value=\"<font color=blue><i> <\/i><\/font>\"&gt;<font color=magenta><i>1<\/i><\/font>&lt;\/option&gt;&lt;option title=\"<font color=purple><i>beans<\/i><\/font>\" value=\"<font color=blue><i>2<\/i><\/font>\"&gt;<font color=magenta><i>2<\/i><\/font>&lt;\/option&gt;&lt;option title=\"<font color=purple><i>beans<\/i><\/font>\" value=\"<font color=blue><i> <\/i><\/font>\"&gt;<font color=magenta><i>3<\/i><\/font>&lt;\/option&gt;&lt;option title=\"<font color=purple><i>beans<\/i><\/font>\" value=\"<font color=blue><i> <\/i><\/font>\"&gt;<font color=magenta><i>4<\/i><\/font>&lt;\/option&gt;&lt;option title=\"<font color=purple><i>beans<\/i><\/font>\" value=\"<font color=blue><i> <\/i><\/font>\"&gt;<font color=magenta><i>5<\/i><\/font>&lt;\/option&gt;&lt;option title=\"<font color=purple><i>beans<\/i><\/font>\" value=\"<font color=blue><i> <\/i><\/font>\"&gt;<font color=magenta><i>6<\/i><\/font>&lt;\/option&gt;&lt;option title=\"<font color=purple><i>beans<\/i><\/font>\" value=\"<font color=blue><i> <\/i><\/font>\"&gt;<font color=magenta><i>7<\/i><\/font>&lt;\/option&gt;&lt;option title=\"<font color=purple><i>beans<\/i><\/font>\" value=\"<font color=blue><i> <\/i><\/font>\"&gt;<font color=magenta><i>8<\/i><\/font>&lt;\/option&gt;&lt;option title=\"<font color=purple><i>beans<\/i><\/font>\" value=\"<font color=blue><i> <\/i><\/font>\"&gt;<font color=magenta><i>9<\/i><\/font>&lt;\/option&gt;&lt;option title=\"<font color=purple><i>beans<\/i><\/font>\" value=\"<font color=blue><i> <\/i><\/font>\"&gt;<font color=magenta><i>10<\/i><\/font>&lt;\/option&gt;&lt;option title=\"<font color=purple><i>beans<\/i><\/font>\" value=\"<font color=blue><i> <\/i><\/font>\"&gt;<font color=magenta><i>11<\/i><\/font>&lt;\/option&gt;&lt;\/select&gt;<br \/>\n<\/code><\/p>\n<p> &#8230; where the HTML select element HTML option subelement <font color=blue><i>value<\/i><\/font> property (being non-blank) determines if a user choice is correct and an index to a position within an HTML table element&#8217;s <i>td<\/i> (cell) subelement <i>id<\/i><font size=1>ed<\/font> ready to display the sentence unjumbled in its &#8220;readable&#8221; format (a huge talent that HTML table and td (cell) elements have (for &#8220;orderliness&#8221;)), and the <font color=purple><i>title<\/i><\/font> property can point back to that sentence&#8217;s relevant word itself, while the HTML option element&#8217;s <font color=magenta><i>innerHTML<\/i><\/font> text is another way to reference the word index (in sentence) data item, so that it features <b>hugely<\/b> in Javascript DOM &#8220;scoring the game&#8221; HTML select &#8220;dropdown&#8221; element <i>onchange<\/i> event code such as &#8230;<\/p>\n<p><code><br \/>\nfunction scoreit(tvo) { \/\/ tvo is the passed in HTML select element reference of the <i>onchange<\/i> event<br \/>\n  var <font color=blue><b>tv=tvo.value<\/b><\/font>, altis=false, wast, waso;<br \/>\n  if (prefix != '' && !usual) {<br \/>\n    <font color=purple><b>wast=tvo.options[tvo.selectedIndex].title;<\/b><\/font><br \/>\n    <font color=magenta><b>waso='td' + tvo.options[tvo.selectedIndex].text;<\/b><\/font><br \/>\n      if ((bits[1].toLowerCase().trim() + '~').replace('.~',' .').replace('?~',' ?').replace('!~',' !').replace('~','').split(' ')[eval(-1 + eval(<font color=magenta><b>tvo.options[tvo.selectedIndex].text<\/b><\/font>))] == <font color=purple><b>tvo.options[tvo.selectedIndex].title<\/b><\/font>.toLowerCase()) {<br \/>\n    usual=false;<br \/>\n    altis=true;<br \/>\n    selcnt--;<br \/>\n    score++;<br \/>\n    tvo.style.backgroundColor='green';<br \/>\n    if (eval(tvo.options[tvo.selectedIndex].text) == 1) {<br \/>\n    document.getElementById(waso).innerHTML=wast.substring(0,1).toUpperCase() + (wast + ' ').substring(1).trim();<br \/>\n    } else {<br \/>\n    document.getElementById(waso).innerHTML=wast;<br \/>\n    }<br \/>\n    tvo.value='';<br \/>\n      } else {<br \/>\n    score--;<br \/>\n    tvo.value='';<br \/>\n    tvo.style.backgroundColor='red';<br \/>\n      }<br \/>\n  } else if (tv.replace(' ','') != '') {<br \/>\n    selcnt--;<br \/>\n    score++;<br \/>\n    tvo.style.backgroundColor='green';<br \/>\n    document.getElementById('td' + tv).innerHTML=<font color=purple><b>tvo.options[tvo.selectedIndex].title;<\/b><\/font><br \/>\n    tvo.value='';<br \/>\n  } else {<br \/>\n    <font color=purple><b>wast=tvo.options[tvo.selectedIndex].title;<\/b><\/font><br \/>\n    <font color=magenta><b>waso='td' + tvo.options[tvo.selectedIndex].text;<\/b><\/font><br \/>\n    if (prefix != '') {<br \/>\n      if ((bits[1].toLowerCase().trim() + '~').replace('.~',' .').replace('?~',' ?').replace('!~',' !').replace('~','').split(' ')[eval(-1 + eval(<font color=magenta><b>tvo.options[tvo.selectedIndex].text<\/b><\/font>))] == <font color=purple><b>tvo.options[tvo.selectedIndex].title<\/b><\/font>.toLowerCase()) {<br \/>\n    usual=false;<br \/>\n    altis=true;<br \/>\n    selcnt--;<br \/>\n    score++;<br \/>\n    tvo.style.backgroundColor='green';<br \/>\n    if (eval(<font color=magenta><b>tvo.options[tvo.selectedIndex].text<\/b><\/font>) == 1) {<br \/>\n    document.getElementById(waso).innerHTML=wast.substring(0,1).toUpperCase() + (wast + ' ').substring(1).trim();<br \/>\n    } else {<br \/>\n    document.getElementById(waso).innerHTML=wast;<br \/>\n    }<br \/>\n    tvo.value='';<br \/>\n      }<br \/>\n    }<br \/>\n    if (!altis) {<br \/>\n    score--;<br \/>\n    tvo.value='';<br \/>\n    tvo.style.backgroundColor='red';<br \/>\n    }<br \/>\n  }<br \/>\n  document.getElementById('score').innerHTML='Score: ' + score + ' from Sentences: ' + goes;<br \/>\n  if (selcnt &lt;= 0) pickasentence();<br \/>\n}<br \/>\n<\/code><\/p>\n<p> &#8230; leaving us scope to allow for sentences for (one, so far) alternative word orderings (still working the one set of HTML select elements and one alternative sentence words data array) &#8230; and don&#8217;t more reasonably complex English sentences have the flexibility to allow for many word ordering possibilities?<\/p>\n<p>And so we have written <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/jumbled_sentences.html\" title='Click picture'>live run<\/a> of the HTML and Javascript <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/jumbled_sentences.html_GETME\" title=\"jumbled_sentences.html\">jumbled_sentences.html<\/a> for your perusal.<\/p>\n<p>We&#8217;d like to give thanks to <i>Five-Minute Activities<\/i> by Penny Ur and Andrew Wright page 44 for ideas for this tutorial, and leave the door open for the user to add their own sentences, as we do with many of our ESL games.  We hope you try the ESL Jumbled Sentences game yourself.<\/p>\n<hr>\n<hr>\n<p id='hjhgt'>Previous relevant <a target=_blank title='HTML\/Javascript Homophones Game Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/htmljavascript-homophones-game-tutorial\/'>HTML\/Javascript Homophones Game Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/homophones.html\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"HTML\/Javascript Homophones Game Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/homophones.jpg\" title=\"HTML\/Javascript Homophones Game Tutorial\"  \/><\/a><p class=\"wp-caption-text\">HTML\/Javascript Homophones Game Tutorial<\/p><\/div>\n<p><a target=_blank title='Homophone information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Homophone'>Homophones<\/a>, the topic of today&#8217;s web application, and <a target=_blank title='Homonym information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Homonym'>homonyms<\/a>, the topic of <a title='HTML\/Javascript Homonyms Game Tutorial' href='#hjhgt'>HTML\/Javascript Homonyms Game Tutorial<\/a> as shown below, are both frequently cited as sources of difficulty for <a target=_blank title='ESL information from Wikipedia ... thanks' href='http:\/\/en.wikipedia.org\/wiki\/English_as_a_second_or_foreign_language'>ESL<\/a> (or &#8220;English as a Second or Foreign Language&#8221;) students.<\/p>\n<p>In the case of homophones, it can be an embarrassment with written English when the wrong homophone is chosen.  As with so many ESL issues, though, practice (not practise) is a great (not grate) idea here, and so we have written <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/homophones.html\" title='Click picture'>live run<\/a> of the HTML and Javascript <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/homophones.html_GETME\" title=\"homophones.html\">homophones.html<\/a> for your perusal.<\/p>\n<p>We&#8217;d like to give thanks to <i>Five-Minute Activities<\/i> by Penny Ur and Andrew Wright pages 69-70 for words to fit into our sentence ideas, and leave the door open for the user to add their own sentences, as we do with many of our ESL games.  We hope you try the ESL Homophones game yourself.<\/p>\n<hr>\n<p id='hjhgt'>Previous relevant <a target=_blank title='HTML\/Javascript Homonyms Game Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/htmljavascript-homonyms-game-tutorial\/'>HTML\/Javascript Homonyms Game Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/homonym_game.html\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"HTML\/Javascript Homonymns Game Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/homonym.jpg\" title=\"HTML\/Javascript Homonyms Game Tutorial\"  \/><\/a><p class=\"wp-caption-text\">HTML\/Javascript Homonyms Game Tutorial<\/p><\/div>\n<p><a target=_blank title='ESL information from Wikipedia ... thanks' href='http:\/\/en.wikipedia.org\/wiki\/English_as_a_second_or_foreign_language'>ESL<\/a> (or &#8220;English as a Second or Foreign Language&#8221;) is a term for the study of English as a Second Language, and is of particular relevance to immigrants to English speaking countries from non-English speaking backgrounds.<\/p>\n<p>One of the most confusing things about learning English, to do with vocabulary, is that English is full of words which sound the same but mean completely different things.  The relationship of such &#8220;same sounding&#8221; words is called a <a target=_blank title='Homonyms information from Wikipedia ... thanks' href='http:\/\/en.wikipedia.org\/wiki\/Homonym'>Homonym<\/a>.  To point out all these Homonyms to ESL students is impossible (or to native speakers, for that matter), because there are too many ways to work an English sentence, that the possibilities for confusion with words of the same sound but different meaning, are almost infinite.<\/p>\n<p>If the ESL teaching is not face to face, what could help here?  Well, we think the use of &#8230;<\/p>\n<ul>\n<li>a thesaurus<\/li>\n<li>a search engine phrase image search<\/li>\n<\/ul>\n<p> &#8230; could help, but we do not pretend that this replaces face to face explanations.<\/p>\n<p>So we&#8217;ve written a <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/homonym_game.html\" title='Click picture'>live run<\/a> of the HTML and Javascript <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/homonym_game.html_GETME\" title=\"homonym_game.html\">homonym_game.html<\/a> supervising an HTML iframe call of <a target=_blank title='Ajax_yql_thesaurus.html' href='http:\/\/www.rjmprogramming.com.au\/PHP\/YQL\/Thesaurus\/Ajax_yql_thesaurus.html--GETME'>Ajax_yql_thesaurus.html<\/a> (changed from the days at <a target=_blank title='Yahoo YQL Web Service JSON Thesaurus Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/yahoo-yql-web-service-json-thesaurus-tutorial\/'>Yahoo YQL Web Service JSON Thesaurus Tutorial<\/a> as per <a target=_blank title='Ajax_yql_thesaurus.html' href='http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/PHP\/YQL\/Thesaurus\/Ajax_yql_thesaurus.html--GETME'>Ajax_yql_thesaurus.html<\/a> so that a URL such as <a target=_blank title='Sense of Humour thesaurus result' href='http:\/\/www.rjmprogramming.com.au\/PHP\/YQL\/Thesaurus\/Ajax_yql_thesaurus.html?startwith=sense%20of%20humour'>Sense of Humour<\/a> will take you straight to the phrase&#8217;s thesaurus lookup).<\/p>\n<p>When you first go in you are presented by the phrase &#8230;<\/p>\n<p><code>Sense of Humour<\/code><\/p>\n<p> &#8230; and if you can project yourself into the frame of mind of someone new to English, maybe, you may wonder about those &#8220;coins&#8221; you may have been using (in Australia, at least), like the 50 &#8220;cents&#8221; coin or the 20 &#8220;cents&#8221; coin, which have that same first word sound.  It can be confusing, so we use a thesaurus to show how &#8220;Sense of Humour&#8221; is a phrase that means something, and that&#8217;s all good, but no thesaurus will work for quite legitimate phrase combinations that are okay, so this &#8220;tool&#8221; is only part of what we need, or is useful.  We think to feed the phrase into a Google search for images can help as well, maybe even more than the thesaurus idea.  As you can imagine, though, nothing beats a face to face explanation.<\/p>\n<p>All that being as it may, give the <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/homonym_game.html\" title='Click picture'>live run<\/a> a go, and make up some of your own in an option of the top dropdown.  If you do, you&#8217;ll soon see how easy they can be assembled, because English is full of Homonym possibilities.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d14796' onclick='var dv=document.getElementById(\"d14796\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/?tag=ESL\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d14796' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d26814' onclick='var dv=document.getElementById(\"d26814\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/dom\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d26814' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d26847' onclick='var dv=document.getElementById(\"d26847\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/sentence\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d26847' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>We have an ESL (or &#8220;English as a Second or Foreign Language&#8221;) Jumbled Sentence construction game today that builds on the basic (game) structure of HTML\/Javascript Homophones Game Tutorial as shown below. Doing this web application, though, taught me, yet &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/htmljavascript-jumbled-sentences-game-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,13,14,15,37],"tags":[354,367,396,476,477,576,652,1631,2076,997,1866,1119,1319],"class_list":["post-26847","post","type-post","status-publish","format-standard","hentry","category-elearning","category-esl","category-event-driven-programming","category-games","category-tutorials","tag-dom","tag-dropdown","tag-esl","tag-game","tag-games-2","tag-html","tag-javascript","tag-onchange","tag-order","tag-programming","tag-select","tag-sentence","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/26847"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=26847"}],"version-history":[{"count":10,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/26847\/revisions"}],"predecessor-version":[{"id":26861,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/26847\/revisions\/26861"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=26847"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=26847"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=26847"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}