Web Analytics Made Easy -
StatCounter Help me please - CodingForum

Announcement

Collapse
No announcement yet.

Help me please

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help me please

    Im a little bit new to javascript so please bear with me. In the script i am writing i would like to have some help in writing information into a series of 4 arrrays.
    I have a series of arrays that list title artist album and time (in therry this is to be utilised in a mp3 type music player.
    I would like to link these arrays to have differing information stored in them .
    Any help would be fantastic as im realy struggleing here.
    Im not sure how to define the global variables and how to link these arryays please help me

    var titleArray;var;[9]
    title[0] = "1";
    title[1] = "2";
    title[2] = "3";
    title[3] = "4";
    title[4] = "5";
    title[5] = "6";
    title[6] = "7";
    title[7] = "8";
    title[8] = "9";
    title[9] = "10";
    var ArtistArray;var;[9]
    Artist[0] = "1";
    Artist[1] = "2";
    Artist[2] = "3";
    Artist[3] = "4";
    Artist[4] = "5";
    Artist[5] = "6";
    Artist[6] = "7";
    Artist[7] = "8";
    Artist[8] = "9";
    Artist[9] = "10";
    var AlbumArray;var;[9]
    Album[0] = "1";
    Album[1] = "2";
    Album[2] = "3";
    Album[3] = "4";
    Album[4] = "5";
    Album[5] = "6";
    Album[6] = "7";
    Album[7] = "8";
    Album[8] = "9";
    Album[9] = "10";
    var TimeArray;var;[9]
    time[0] = "1";
    time[1] = "2";
    time[2] = "3";
    time[3] = "4";
    time[4] = "5";
    time[5] = "6";
    time[6] = "7";
    time[7] = "8";
    time[8] = "9";
    time[9] = "10";

    i was hoping to incorperate the arrays above in this html

    <HTML><HEAD>
    <META http-equiv=Content-Type content="text/html; charset=windows-1252">
    <META content="MSHTML 6.00.2900.2912" name=GENERATOR></HEAD>
    <BODY onload=javascript:resetImp();>
    <FORM name=theImp action="" method=post>
    <DIV align=center>
    <TABLE cellSpacing=0 cellPadding=4 width=800 border=1>
    <TBODY>
    <TR align=right bgColor=#aaaaaa>
    <TD bgColor=#000000 colSpan=3>
    <P align=center><FONT face="Arial, Helvetica, sans-serif"
    color=#ffffff><STRONG>Ali's music player</STRONG></FONT></P></TD></TR>
    <TR align=middle bgColor=#aaaaaa>
    <TD colSpan=3><INPUT id=impStatus maxLength=255 size=80
    value="Welcome to the IMP!" name=impStatus> </TD></TR>
    <TR>
    <TD width=350 bgColor=#aaaaaa height=200>
    <TABLE cellSpacing=0 cellPadding=2 border=1>
    <TBODY>
    <TR>
    <TD>
    <TABLE height=200 cellSpacing=0 cellPadding=2 width=250
    bgColor=#cccccc border=0>
    <TBODY>
    <TR vAlign=center>
    <TD align=left height=25>
    <P><STRONG><FONT face="Arial, Helvetica, sans-serif"
    size=2>Title</FONT></STRONG></P></TD>
    <TD align=left height=20><INPUT id=songTitle name=songTitle>
    </TD></TR>
    <TR vAlign=center>
    <TD align=left height=20>
    <P><STRONG><FONT face="Arial, Helvetica, sans-serif"
    size=2>Artist</FONT></STRONG></P></TD>
    <TD align=left height=20><INPUT id=songArtist name=songArtist>
    </TD></TR>
    <TR vAlign=center>
    <TD align=left height=20>
    <P><STRONG><FONT face="Arial, Helvetica, sans-serif"
    size=2>Album</FONT></STRONG></P></TD>
    <TD align=left height=20><INPUT id=songAlbum name=songAlbum>
    </TD></TR>
    <TR vAlign=center>
    <TD align=left height=20>
    <P><STRONG><FONT face="Arial, Helvetica, sans-serif"
    size=2>Time </FONT></STRONG><FONT
    face="Arial, Helvetica, sans-serif" size=2>(s)</FONT></P></TD>
    <TD align=left height=25><INPUT id=songTime name=songTime>
    </TD></TR>
    <TR>
    <TD vAlign=top align=left height=25>
    <P>&nbsp;</P></TD>
    <TD vAlign=top align=left height=25>&nbsp;</TD></TR>
    <TR align=right>
    <TD vAlign=top colSpan=2 height=75>
    <P><STRONG><FONT face="Arial, Helvetica, sans-serif"
    size=2>Track number </FONT></STRONG><SELECT name=trackNumbers>
    <OPTION value=0 selected>Track 1</OPTION> <OPTION
    value=1>Track 2</OPTION> <OPTION value=2>Track 3</OPTION>
    <OPTION value=3>Track 4</OPTION> <OPTION value=4>Track
    5</OPTION> <OPTION value=5>Track 6</OPTION> <OPTION
    value=6>Track 7</OPTION> <OPTION value=7>Track 8</OPTION>
    <OPTION value=8>Track 9</OPTION> <OPTION value=9>Track
    10</OPTION></SELECT>
    </P></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD>
    <TD vAlign=center align=middle width=100 bgColor=#cccccc>
    <P><INPUT id=resetButton onclick=javascript:resetClicked(); type=button value=Reset name=resetButton>

    <P>&nbsp;</P>
    <P>&nbsp;</P><INPUT id="Add Track" onclick=javascript:addTrack(); type=button value="Add Track" name="Add Track">

    <P><INPUT id=deleteButton onclick=javascript:deleteTrack(); type=button value="Delete Track" name=deleteButton>
    </P></TD>
    <TD vAlign=top align=left width=250 bgColor=#cccccc>
    <TABLE height=200 cellSpacing=0 cellPadding=2 width=250 border=1>
    <TBODY>
    <TR>
    <TD vAlign=top align=left width=250 bgColor=#ffcc98 height=200>
    <DIV id=impTrackListing align=left>
    <P><FONT face="Arial, Helvetica, sans-serif" size=2>Your IMP is
    empty
    </P></DIV></FONT></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></DIV></FORM></BODY></HTML>

  • #2
    An array is defined by the syntax

    var titleArray = new Array();
    var artistArray = new Array(); etc.

    Optionally the array constructor may take an argument to specify the number of array elements to create,

    e.g. var titleArray = new Array(10); // ten elements indexed 0-9

    Then you define the elements as you have done:-

    titleArray[0] = "1" // not "title" - the array names must match precisely. [0] is the first element.

    "I would like to link these arrays to have differing information stored in them." Sorry, not sure what that means. Please specify more clearly what you want to do.
    Last edited by Philip M; Sep 24, 2006, 03:52 AM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

    Comment

    Working...
    X