Arrays in Javascript (correlating)

I'm having trouble figuring out what needs to be included in this code

(I apologize that it's in German, it's an array corresponding to images for JavaScript.)

function namenZuBildern(){ 
   var bilder = new Array( "000227", "000228",
   "000229", "000231", "000233", "000235", "000237", "000238", "000239", 
   "000241", "000242", "000245", "000247", "000248", "000249", "000250",
   "000252", "000253", "000254", "000258", "000259", "000261", "000262" ) ; 

   var index = document.getElementById('einform').person.selectedIndex;
   document.images[0].src="#" + bilder[index] + ".jpg"; 
}  

Why are there all these numbers inside newArray()? Are they the positions of the pictures?

And I understand that I need to insert the id here

document.getElementById('...').person.selectedIndex;    

But why is it [0] when I have 4 pictures?

Please help

Answer №1

Given that the bilder array is utilized to assign the file names as values for the images' src attribute, it seems likely they are correlated.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for choosing all elements in a form that have a specific class assigned

I am attempting to target all fields in a form with a specific class name and then select all the remaining fields. This is my form: <form style="margin:20px 0" id="myform_2"> <p> Query Name : <input i ...

Changing the format of a numerical value to include commas for every 1000 increment

I'm trying to find a way to format numbers in a specific manner, such as changing 1234567 into 1,234,567. However, I've run into some issues when attempting to use the currency pipe of TypeScript. It adds USD or $ in front of the number, which i ...

Adding a Bold Headline in Select2: A Quick Guide

I have thoroughly searched through all of the select2 documentation but unfortunately, I could not find any information on how to add bold headlines. Can anyone please provide a full code example (including CSS) on how to accomplish this? ...

Tips for retrieving JSON data from an AJAX call and displaying it pre-filled in an input field

Here is the code snippet I used to receive a response in JSON format, but when I try to display the response using alert(response.Subject);, it shows as "undefined". HTML: <input type="text" id="subject" value='Subject'> Javascript: $.a ...

The <a href="#divtagid"> link is incapable of triggering the opening of the div tag when called from JavaScript

I need help with displaying the content of a div with the id "hello" in maindiv when clicking on the href "Click Here", but it's not working as expected. Here is the code I have: $(document).ready(function() { var newhtml = '<a href="#he ...

WebStorm not recognizing NodeJS Core Modules in External Libraries

As a newcomer to NodeJS and WebStorm, I am currently diving into a tutorial on creating an Express app. In the tutorial, the instructor always gets prompted with "Configure NodeJS Core Module Sources" including the URL nodeJS.org when creating a new NodeJ ...

What are the methods to determine if vue-router is being utilized within the present Vue instance?

I am working on creating a library that includes a vue.js component with navigation elements. The goal is for this component to be flexible, able to function both with and without vue router. When used with the router, it will utilize <router-link> ...

The Bootstraps CSS style doesn't seem to be working properly or being overridden within an Angular

I have seen similar questions asked before, but none of the solutions provided have fixed my issue. It appears that the styles are being applied initially but then overridden by something else, and I am unable to identify what is causing this. The only r ...

The communication feature using jQuery and PHP is not saving information to the database

I'm currently in the process of setting up a chat page using jQuery and PHP. However, I've encountered an issue where although the Added echo statement appears after submitting data on my simple form, the information is not actually being added t ...

What is the Proper Way to Import Three.js Modules in a Vue Application?

My goal is to utilize three.js for displaying a gltf file. To achieve this, I need to import the GLTFLoader module from the three.js node package. As per the documentation, the correct way to import it is: import { GLTFLoader } from 'three/examples/ ...

Unable to prevent AJAX request initiated by setTimout

Despite coming across various posts discussing how to abort AJAX requests using the .abort() function, I am still unable to make it work in my case. One example of such discussion can be found in this particular post. Currently, my code initiates repeated ...

Accessing objects from a loop in JavaScript

In an effort to adhere to the principle of avoiding "polluting the global namespace" and due to the consensus that global variables are typically discouraged, I made a modification in my code by replacing global variables: stBgAsset15_src = $image.at ...

The Angular User Interface Router is a versatile tool for managing

Managing a large application with over 1500 pages can be challenging. I have opted to use angular UI Router for routing. I am interested in learning about the best practices for handling routing in such a vast application. Should I define all routes in ...

Convert CSV into an object with additional attribute

I'm attempting to import data from a CSV file into a d3 tree graph. While I've successfully loaded the JSON version of the data, the d3.csv parser isn't returning the expected string. Some approaches I've tried include: treeData.forEa ...

Modifying the CSS properties of elements with identical IDs

Encountering an issue while attempting to modify the CSS property of elements with similar IDs using JavaScript. Currently, running a PHP loop through hidden elements with IDs such as imgstat_1, imgstat_2, and so forth. Here is the code snippet being emp ...

Exploring the wonders of CSS with Socialchef

Hey, I recently came across a solution on Stack Overflow where they provided code for SocialChef to convert decimal inputs into fractions. I'm wondering how I can write or incorporate some code to input fractions and mantissa as a fraction... I ...

Customizing Row Background Color in Bootstrap

Currently working on a project www.codepen.io/anon/pen/yMmjZb The problem I am facing is with my 3rd row (the one with the 3 columns) where the background color is bleeding beyond the intended boundary. My suspicion is that it's due to the row span ...

What are the best ways to store internal files in node.js for faster access?

I have been utilizing routing functions like the one mentioned below to replicate the overall design of my website (A.jade): exports.overview = function(req, res, next) { res.render('A', { main: jade.renderFile('./views/B.jade' ...

Issues with React router arise once the app has been built

I am new to utilizing react and react-router in my project. I have built the application using create-react-app and now I am facing an issue with routing between two main pages. After trying different approaches, I managed to get it working during develop ...

Receiving the outcome of an asynchronous function in JavaScript

async function retrieveKey() { try { var key = await dec.awsDecrypt('dev-frontend') return key; } catch(err) { } } //calling the function const result = retrieveKey() In the code snippet above, there is an asynchronous ...