javascript - Transferring values using js switch -


using jstorage.js, i've transferred values, referring english programs "starting", "primary", "uni" , on, 1 page in joomla site using script. works ok. each of values displayed in title on relevant second page. here js:

jquery(document).ready(function(){  "use strict";   jquery("p.enrol_para").on("click", function(evnt){       var elementid = evnt.target.id;        jquery.jstorage.set("program", elementid);      });   jquery("div#register_title").prepend(document.createtextnode(jquery.jstorage.get("program")+" ")); }); 

and html fragment:

<p class="enrol_para"><span class="enrol_text"><a href="/index.php/registration-starting" id="starting" class="enrol_btn">enrol/ลงทะเบียน</a></span></p> 

however, want "starting" show "starting english", "primary" show "primary school" , on. tried using js switch statment in way:

jquery(document).ready(function(){     "use strict";     jquery("p.enrol_para").on("click", function(evnt){         var elementid = evnt.target.id;          jquery.jstorage.set("program", elementid);     });     var progname = jquery.jstorage.get("program");         switch (progname){         case "starting":           jquery("div#register_title").prepend(document.createtextnode("starting english"+" "));           break;         case "primary":           jquery("div#register_title").prepend(document.createtextnode("primary school english"+" "));           break;         case "high":           jquery("div#register_title").prepend(document.createtextnode("high school english"+" "));           break;         case "senior":           jquery("div#register_title").prepend(document.createtextnode("senior school english"+" "));           break;         case "uni":           jquery("div#register_title").prepend(document.createtextnode("university english"+" "));           break;         case "profession":           jquery("div#register_title").prepend(document.createtextnode("professional , career english"+" "));           break;         default:           jquery("div#register_title").prepend(document.createtextnode("general english"+" "));         } }); 

but doesn't work. nothing displayed in various page titles. jshint has oked syntax. thought using switch statement best way go here, perhaps not. appreciated.

here script did trick:

jquery(document).ready(function(){    "use strict";     jquery("a.enrol_btn").on("click", function(){          jquery.jstorage.set("program", jquery(this).attr("data-program"));     });     jquery("div#register_title").prepend(document.createtextnode(jquery.jstorage.get("program"))); }); 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -