Connect with Facebook Lost Password?


Go Back   CodeCall Programming Forum > Software Development > Tutorials > Javascript

Javascript Javascript Tutorials and Code

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-03-2006, 09:52 AM
TcM's Avatar   
TcM TcM is offline
Code Warrior
 
Join Date: Aug 2006
Posts: 9,840
Blog Entries: 6
Rep Power: 82
TcM is a name known to allTcM is a name known to allTcM is a name known to allTcM is a name known to allTcM is a name known to allTcM is a name known to all
Default JavaScript:Tutorial, Using Arrays

Introduction:-
Usually this is a difficult thing when it comes to programming and usually people get mixed up with arrays.

Solution:-
Make this Function between the <head> tags:-

Code:
<SCRIPT language="JavaScript">

function array_use()
{

var msg= new Array(8)
msg[0]="Msg1";
msg[1]="Msg2";
msg[2]="Msg3";
msg[3]="Msg4";
msg[4]="Msg5";
msg[5]="Msg6";
msg[6]="Msg7";
msg[7]="Msg8";

var i=0;



for (i=0; i<8; i++)

  {
     alert(msg[i]);
  }

}

</SCRIPT>
Instead of

Code:
var msg= new Array(8)
msg[0]="Msg1";
msg[1]="Msg2";
msg[2]="Msg3";
msg[3]="Msg4";
msg[4]="Msg5";
msg[5]="Msg6";
msg[6]="Msg7";
msg[7]="Msg8";
You can make (Untested)

Code:
var msg = new Array("msg1","msg2","msg3","msg4","msg5","msg6","msg7","msg8");
And call it with something like this:-
Code:
<BODY onLoad="array_use()">
Explanation:-
Code:
for (i=0; i<8; i++)

  {
     alert(msg[i]);
  }
This is a Loop that will display a msg and increase i by one every time and it will go on until i<8

A Preview:-


Conclusion:-
As Always Feedback is welcome and the full source is attached!!
Attached Files To view attachments in this forum your post count must be 1 or greater. You currently have 0 posts.

Last edited by TcM; 06-26-2008 at 01:30 PM..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 08-23-2007, 09:03 AM
RikkoSuperb's Avatar   
Newbie
 
Join Date: Aug 2007
Location: holywood, county down, northern ireland
Age: 27
Posts: 20
Rep Power: 0
RikkoSuperb is an unknown quantity at this point
Default

What else can you do with arrays? I have used them in coursework but the examples are lame - like amount of books borrowed from a library that are printed to the document for the user to view. wow. ground breaking stuff? methinks not.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 06-25-2008, 01:34 AM
Newbie
 
Join Date: Jun 2008
Posts: 3
Rep Power: 0
Rohit is an unknown quantity at this point
Default Re: JavaScript:Tutorial, Using Arrays

Thanks to share this information,good information about how we can use array in <head> tag
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 06-25-2008, 03:02 AM
TcM's Avatar   
TcM TcM is offline
Code Warrior
 
Join Date: Aug 2006
Posts: 9,840
Blog Entries: 6
Rep Power: 82
TcM is a name known to allTcM is a name known to allTcM is a name known to allTcM is a name known to allTcM is a name known to allTcM is a name known to all
Default Re: JavaScript:Tutorial, Using Arrays

Welcome.

Thanks for positive comment.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 06-25-2008, 03:18 PM
Xav's Avatar   
Xav Xav is offline
Code Slinger
 
Join Date: Mar 2008
Location: The North Pole
Posts: 13,210
Blog Entries: 13
Rep Power: 105
Xav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud of
Send a message via MSN to Xav
Default Re: JavaScript:Tutorial, Using Arrays

Your code isn't particularly efficient. A shorter way to declare an array like that:
javascript Code:
  1. var msg = new Array("msg1","msg2","msg3","msg4","msg5","msg6","msg7","msg8");
__________________

Quote:
Originally Posted by Jordan View Post
Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 06-25-2008, 04:22 PM
TcM's Avatar   
TcM TcM is offline
Code Warrior
 
Join Date: Aug 2006
Posts: 9,840
Blog Entries: 6
Rep Power: 82
TcM is a name known to allTcM is a name known to allTcM is a name known to allTcM is a name known to allTcM is a name known to allTcM is a name known to all
Default Re: JavaScript:Tutorial, Using Arrays

These tutorials are not about efficiency, but about getting the basic thing and the concept of it into the readers mind.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 06-26-2008, 11:08 AM
Xav's Avatar   
Xav Xav is offline
Code Slinger
 
Join Date: Mar 2008
Location: The North Pole
Posts: 13,210
Blog Entries: 13
Rep Power: 105
Xav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud of
Send a message via MSN to Xav
Default Re: JavaScript:Tutorial, Using Arrays

I'm just saying, it's an awful lot of code there, which could easily be simplified.
__________________

Quote:
Originally Posted by Jordan View Post
Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 06-26-2008, 12:33 PM
TcM's Avatar   
TcM TcM is offline
Code Warrior
 
Join Date: Aug 2006
Posts: 9,840
Blog Entries: 6
Rep Power: 82
TcM is a name known to allTcM is a name known to allTcM is a name known to allTcM is a name known to allTcM is a name known to allTcM is a name known to all
Default Re: JavaScript:Tutorial, Using Arrays

Yeah, but makes it harder for someone trying to learn the concept of Arrays.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 06-26-2008, 12:34 PM
Xav's Avatar   
Xav Xav is offline
Code Slinger
 
Join Date: Mar 2008
Location: The North Pole
Posts: 13,210
Blog Entries: 13
Rep Power: 105
Xav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud of
Send a message via MSN to Xav
Default Re: JavaScript:Tutorial, Using Arrays

I can't see how it is harder - if anything it's easier, because you don't need to concern yourself with array indices - simply define the elements.
__________________

Quote:
Originally Posted by Jordan View Post
Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 06-26-2008, 12:37 PM
TcM's Avatar   
TcM TcM is offline
Code Warrior
 
Join Date: Aug 2006
Posts: 9,840
Blog Entries: 6
Rep Power: 82
TcM is a name known to allTcM is a name known to allTcM is a name known to allTcM is a name known to allTcM is a name known to allTcM is a name known to all
Default Re: JavaScript:Tutorial, Using Arrays

But as Arrays start with 0 and not with 1, if you don't make those indices, they might get confused. And they will not understand the concept of

Code:
alert(msg[i]);
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Python arrays... Sir_Rimo Python 3 06-20-2007 08:54 AM
Arrays clookid PHP Tutorials 1 01-11-2007 08:30 PM
Are arrays sort of like matrices? Sionofdarkness Java Help 5 08-21-2006 02:30 PM
Arrays Sionofdarkness C and C++ 5 07-26-2006 05:35 PM
Arrays in NET 2.0 or CLI Managed C++ Void Managed C++ 1 07-18-2006 07:57 PM


All times are GMT -5. The time now is 03:24 PM.

Freelance Jobs

XML/XSL: Need code for Book with Chapers using XML
Create an XML file for a book of your creation, and a basic CSS file that will format it to display ...
Earn: $40.00


C++/C: Simple firework cue sequencer
What I require is a rework of a simple cue sequencer. I have a piece of hardware (an Arduino boar...
Earn: $50.00


HTML/XHTML: Menu Rework - ASCIIBin
I'm placing this in the HTML/XHTML section of the Freelance site but you are not limited to HTML. Wh...
Earn: $20.00



CodeCall Goal

Goal #1: 1,000 Blogs
Goal #2: 1,000 Wiki Pages
Goal #3: 300,000 Posts
Goal #4: 20,000 Threads
Done: 30%, 23%, 56%, 75%

Ads