JavaScript Display images from two dropdown menus display images from s3,display images from json array,display

Running into a bit of a brick wall here with my limited coding knowledge.

I have a dropdown menu which displays images upon selection, that's all well and good. How do I add a second dropdown and corresponding image without the dropdowns feeding into/interfering with each other?

Ideally I want to end up with two dropdown boxes side by side - each reading from the same set of image variables - then two images side by side beneath them.

Here is the code for the single working one; Head contains:

var linkData = [
  ['http://i.imgur.com/4ECkKqG.png'],
  ['http://i.imgur.com/98zZKAm.png'],
]
  //preload the pics
  var picO = new Array();
  for(i=0; i < linkData.length; i++){
  picO[i] = new Image();
  picO[i].src = linkData[i][0];
}

function show(val) {
  document.getElementById('picture').src = picO[val-1].src;
}
window.onload=function(){
  show(1);
}

body

<div>
    <select onchange="show(this.value);">
      <option value="1">Option 1</option>
      <option value="2">Option 2</option>
    </select>
    <br/>
    <a><img id="picture" src="" /></a> 
</div>
Answer:1

First of all using picO array and new Image() to create new Images and storing them in this array is useless here just get rid of it, then just use a function where you pass the current dropdown and the id of the target img, and call it on each select change event.

This is a working snippet:

var linkData = [
  ['http://i.imgur.com/4ECkKqG.png'],
  ['http://i.imgur.com/98zZKAm.png'],
]

function changeImage(select, id) {
  var img = document.getElementById(id);
  img.src = linkData[(select.value) - 1][0];
  return false;
}
<select id="select1" onchange="changeImage(this, 'image1')">
  <option value="1">Option 1</option>
  <option value="2">Option 2</option>
</select><br/>
<img id="image1" src="http://i.imgur.com/4ECkKqG.png" />

<br>
<select id="select2" onchange="changeImage(this, 'image2')">
  <option value="1">Option 1</option>
  <option value="2">Option 2</option>
</select><br/>
<img id="image2" src="http://i.imgur.com/4ECkKqG.png" />
Answer:2

window.getSelection().anchorNode returns quite a lot of details about the node where the user clicked to start the selection, but how can I get attributes of that text node, like class, id etc.? ...

window.getSelection().anchorNode returns quite a lot of details about the node where the user clicked to start the selection, but how can I get attributes of that text node, like class, id etc.? ...

I have a form and wanted to retain its values when form loads without using any web storage. I want to use only Javascript or jQuery. Moreover, I want that form values such as radio and dropdown ...

I have a form and wanted to retain its values when form loads without using any web storage. I want to use only Javascript or jQuery. Moreover, I want that form values such as radio and dropdown ...

  1. retain form values after submit javascript
  2. retain form values after back button
  3. retain form values after submit php
  4. retain form values after submit
  5. retain form values after submit jsp
  6. retain form values after submit html5
  7. retain form values after submit mvc
  8. retain form values after submit jquery
  9. retain form values after submit django
  10. codeigniter retain form values
  11. struts2 retain form values
  12. html form retain values after submit
  13. spring mvc retain form values
  14. how to retain form values after refresh php
  15. how to retain form values after submit in spring mvc
  16. how to retain form values in jsp
  17. how to retain form values after submit in struts
  18. php form retain values

What is the most efficient way to check a certain condition on every element of an array and return false if one or more elements do not meet the condition, for example, I have this array for example ...

What is the most efficient way to check a certain condition on every element of an array and return false if one or more elements do not meet the condition, for example, I have this array for example ...

  1. check every element in list python
  2. check every element in array javascript
  3. check every element in array java
  4. check every element in numpy array
  5. check every element matrix matlab
  6. check every element in array python
  7. check every element in array php
  8. js check every element in array
  9. matlab check every element
  10. how to check every element in array

It works but I don't understand what the hell I did, I need to know if the "js", "css" properties is what the task looks for??? module.exports = function(grunt) { grunt.initConfig({ concat: { ...

It works but I don't understand what the hell I did, I need to know if the "js", "css" properties is what the task looks for??? module.exports = function(grunt) { grunt.initConfig({ concat: { ...

  1. grunt js files