JavaScript How do you load a new html page when select an item from a <select> html element load html page in div,load html page from javascript,

I currently have a button for each language to allow users to view website in difference languages

<a target='_blank' href="http://www.jthink.net/songkong/en" title='English'><img src="http://static.albunack.net/images/flags/flags-iso/shiny/32/GB.png" alt="English" height="32" width="32" valign="top"></a>&nbsp;
<a target='_blank' href="http://www.jthink.net/songkong/de" title='Deutsch'><img src="http://static.albunack.net/images/flags/flags-iso/shiny/32/DE.png" alt="Deutsch" height="32" width="32"  valign="top"></a>&nbsp;
<a target='_blank' href="http://www.jthink.net/songkong/es" title='Español'><img src="http://static.albunack.net/images/flags/flags-iso/shiny/32/ES.png" alt="Español" height="32" width="32"  valign="top"></a>&nbsp;
<a target='_blank' href="http://www.jthink.net/songkong/fr" title='Français'><img src="http://static.albunack.net/images/flags/flags-iso/shiny/32/FR.png" alt="Français" height="32" width="32"  valign="top"></a>&nbsp;

I now want to use a drop down to save space

<select>
  <option value="en">English</option>
  <option value="de">Deutsch</option>
  <option value="es">Español</option>
  <option value="fr">Français</option>
</select> 

but how do I make a selection trigger the correct page to be loaded

Answer:1

As simple as this:

<select onchange="location.target='_blank' href='http://www.jthink.net/songkong/'+this.value;">
  <option value="en">English</option>
  <option value="de">Deutsch</option>
  <option value="es">Español</option>
  <option value="fr">Français</option>
</select>

Let me know if it doesn't work.

You can try unobtrusive way too:

<select id="langchange">
  <option value="en">English</option>
  <option value="de">Deutsch</option>
  <option value="es">Español</option>
  <option value="fr">Français</option>
</select>
document.querySelector('#langchange').addEventListener('change', function () {
  location.href = "http://www.jthink.net/songkong/" + this.value;
});
Answer:2

use this onchange attribute in your select:

<select onchange="window.location = this.options[this.selectedIndex].value;">

and set the value of each option to the appropriate url

JSFIDDLE DEMO

Answer:3

I have 4 check boxes, and depending on which one/pair is selected I want a specific array to be displayed on the page. I'm relatively new to angularjs so I'm not sure how to get this to work. So how ...

I have 4 check boxes, and depending on which one/pair is selected I want a specific array to be displayed on the page. I'm relatively new to angularjs so I'm not sure how to get this to work. So how ...

  1. angularjs display array of objects
  2. angularjs display array in html
  3. angularjs display array of strings
  4. angularjs display array list
  5. angularjs display array
  6. angularjs display array in table
  7. angularjs display array index
  8. angularjs display array data
  9. angularjs display json array
  10. angularjs display count of array
  11. angularjs display image byte array
  12. angularjs display element of array

I have a small and quite standard application that: Fetches objects from the server Renders the objects and allows some editing on them. If it is important, this editing only affects DS.hasMany ...

I have a small and quite standard application that: Fetches objects from the server Renders the objects and allows some editing on them. If it is important, this editing only affects DS.hasMany ...

I'm looking for a list of time zones that corresponds to major cities. Like what java.util.TimeZone can provide. I mean, I want to resolve the America/Los_Angeles identifier to UTC-8:00 in javascript. ...

I'm looking for a list of time zones that corresponds to major cities. Like what java.util.TimeZone can provide. I mean, I want to resolve the America/Los_Angeles identifier to UTC-8:00 in javascript. ...

  1. timezones list json

Please look at below codes: Case 1: var a = { b: function(){ console.log(a) }, c:1 }; Case 2: var a = { b:a, c:1 }; Now when I write this : a.b() // for first console....

Please look at below codes: Case 1: var a = { b: function(){ console.log(a) }, c:1 }; Case 2: var a = { b:a, c:1 }; Now when I write this : a.b() // for first console....

  1. javascript object accessing
  2. javascript object accessing properties
  3. javascript object accessing values
  4. javascript accessing object properties with variables
  5. javascript accessing object properties dynamically
  6. javascript accessing object keys
  7. javascript accessing object in array
  8. javascript accessing object properties by index
  9. javascript accessing object fields
  10. javascript accessing object elements
  11. js accessing object properties
  12. js accessing object values
  13. js accessing object
  14. basic javascript accessing object properties with variables
  15. basic javascript accessing object properties with bracket notation
  16. basic javascript accessing object properties with dot notation
  17. basic javascript accessing object properties with variables freecodecamp
  18. basic javascript accessing object properties with dot notation freecodecamp
  19. accessing javascript object variables
  20. accessing javascript object in html