I have a select drop down:
<select lang="en" >
<option label=" Select a keyboard language" selected="selected" />
<option value="af" label="Afrikaans / Afrikaans" />
<option value="sq" label="Albanian / shqipe" />
<option value="ar" label="Arabic / العربية" />
<option value="hy" label="Armenian / Հայերեն" />
........
</select>
I have external JavaScript files (C:[PATH]\\js_files): af.js, sq.js, ar.js, hy.js, etc.
How do I call and load the relative external JavaScript files when a user makes a language selection?
My js skills are not so great as to solve this.
Thanks.
So essentially you are only looking for this? :
javascript in head:
function loadJS(v){
var d=document, h=d.getElementsByTagName('head')[0], newScript;
try {h.removeChild(d.getElementById('lib_lang'));} catch (e){}
newScript = d.createElement('script');
newScript.id = 'lib_lang';
newScript.type = 'text/javascript';
newScript.src = '[PATH]/'+v+'.js'; // change your path here
h.appendChild(newScript);
}
html in body:
<select lang="en" onchange="loadJS(this.value)">
<option selected="selected" disabled="true"> Select a keyboard language</option>
<option value="af">Afrikaans / Afrikaans</option>
<option value="sq">Albanian / shqipe</option>
<option value="ar">Arabic / العربية</option>
<option value="hy">Armenian / Հայերեն</option>
</select>
Hope that helps, good luck!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.