LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-13-2023, 03:54 AM   #1
errigour
Member
 
Registered: May 2009
Posts: 366

Rep: Reputation: 6
Java Script Question


I have this code i'm trying to use but it doesn't seem to be concatting innerHTML or something because when I run it it doesn't work there are no images in the element mods which is a div. Is there any valid way to do that? I want to point out that the rest of the scripts run so it looks like it should be working but again no images display in mods element and that's what i'm trying to do. Is that a valid way to define innerHTML?


Code:
    document.getElementById('mods').innerHTML += '<br>';
Code:
                const ship = new Array('Shuttle', 0, 55, 25, 100, 100, 100, 1000, 250000, 2);
                ship[10] = new Array('images/ships/mods/Turrets.png', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '');
                for(i=0;i<30;i++) {
                    if(ships[10][i] != '')
                        document.getElementById('mods').innerHTML += '<image src=' + ships[10][i] + ' alt=' + ships[10][i] + '>';
                    else
                        document.getElementById('mods').innerHTML += '<image src=images/ships/EmptyDockingBay.png alt=/html/images/ships/EmptyDockingBay.png>';

                    if( i == 9 || i == 19 )
                        document.getElementById('mods').innerHTML += '<br>';

                }
 
Old 03-13-2023, 04:00 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Well I would say the most obvious thing is you seem to be using both "ship" and "ships" as array names, unless there is a new feature that pluralizes array names??
 
1 members found this post helpful.
Old 03-13-2023, 04:02 AM   #3
errigour
Member
 
Registered: May 2009
Posts: 366

Original Poster
Rep: Reputation: 6
I tried this and it doesn't work either,
Code:
    for(i=0;i<30;i++) {
        document.getElementById('mods').innerHTML += '<image src=images/ships/EmptyDockingBay.png alt=/html/images/ships/EmptyDockingBay.png>';
    }
 
Old 03-13-2023, 04:03 AM   #4
errigour
Member
 
Registered: May 2009
Posts: 366

Original Poster
Rep: Reputation: 6
that was my problem thanks. its fixed!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: How to install Oracle Java Series (JAVA 9 to JAVA 6) via PPA in Ubuntu & Mint LXer Syndicated Linux News 0 12-20-2016 04:30 PM
LXer: Install JAVA (Oracle JAVA & openJDK) via JAVA Alternatives Method LXer Syndicated Linux News 0 12-13-2016 12:44 PM
[SOLVED] Java Woes: A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be available ... chytraeus Slackware 10 11-27-2010 10:04 AM
Rant: Java java java..... Jeebizz General 28 01-29-2009 02:23 PM
java java oh java chingasman Linux - General 2 02-20-2003 11:41 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration