I would like to add multiple loop statements to the following to shorten
the code:
var card0 = asLucky[0];
var card1 = asLucky[1];
var card2 = asLucky[2];
var card3 = asLucky[3];
var card4 = asLucky[4];
var card5 = asLucky[5];
var card6 = asLucky[6];
var card7 = asLucky[7];
var card8 = asLucky[8];
var card9 = asLucky[9];
var card10 = asLucky[10];
var card11 = asLucky[11];
var card12 = asLucky[12];
var card13 = asLucky[13];
var card14 = asLucky[14];
var card15 = asLucky[15];
var card16 = asLucky[16];
player6 = open('javascript:opener.cards6()', 'player6',
'left=10,width=50,height=50,menubar=yes');
player6.focus();
function cards6() {
return "<title>Player 6 Cards</title><br><font
color=white>"+card10+"<BR>"+card11+"</font>";
}
player5 = open('javascript:opener.cards5()', 'player5',
'left=10,width=200,height=100,menubar=yes');
player5.focus();
function cards5()
{
return "<title>Player 5 Cards</title><br><font
color=white>"+card8+"<BR>"+card9+"</font>";
}
player4 = open('javascript:opener.cards4()', 'player4',
'left=10,width=200,height=100,menubar=yes');
player4.focus();
function cards4()
{
return "<title>Player 4 Cards</title><br><font
color=white>"+card6+"<BR>"+card7+"</font>";
}
player3 = open('javascript:opener.cards3()', 'player3',
'left=10,width=200,height=100,menubar=yes');
player3.focus();
function cards3()
{
return "<title>Player 3 Cards</title><br><font
color=white>"+card4+"<BR>"+card5+"</font>";
}
player2 = open('javascript:opener.cards2()', 'player2',
'left=10,width=200,height=100,menubar=yes');
player2.focus();
function cards2()
{
return "<title>Player 2 Cards</title><br><font
color=white>"+card2+"<BR>"+card3+"</font>";
}
player1 = open('javascript:opener.cards1()', 'player1',
'left=10,width=200,height=100,menubar=yes');
player1.focus();
function cards1()
{
return "<title>Player 1 Cards</title><br><font
color=white>"+card0+"<BR>"+card1+"</font>";
} 4 1242
dmanklein wrote: I would like to add multiple loop statements to the following to shorten the code:
var card0 = asLucky[0]; var card1 = asLucky[1]; var card2 = asLucky[2]; var card3 = asLucky[3]; var card4 = asLucky[4]; var card5 = asLucky[5]; var card6 = asLucky[6]; var card7 = asLucky[7]; var card8 = asLucky[8]; var card9 = asLucky[9]; var card10 = asLucky[10]; var card11 = asLucky[11]; var card12 = asLucky[12]; var card13 = asLucky[13]; var card14 = asLucky[14]; var card15 = asLucky[15]; var card16 = asLucky[16];
for(var i=0;i<16;1++){eval("var card"+i+"="+asLucky[i];)}
But why bother? Just use asLucky[n] where you use card...n
See below:
player6 = open('javascript:opener.cards6()', 'player6', 'left=10,width=50,height=50,menubar=yes'); player6.focus();
function cards6() { return "<title>Player 6 Cards</title><br><font color=white>"+card10+"<BR>"+card11+"</font>"; }
function cards6() {
return "<title>Player 6 Cards</title><br><font
color=white>"+asLucky[10]+"<BR>"+asLucky[11]+"</font>";
}
This looks like substandard HTML, though.
Good luck.
Mick player5 = open('javascript:opener.cards5()', 'player5', 'left=10,width=200,height=100,menubar=yes'); player5.focus();
function cards5() { return "<title>Player 5 Cards</title><br><font color=white>"+card8+"<BR>"+card9+"</font>"; }
player4 = open('javascript:opener.cards4()', 'player4', 'left=10,width=200,height=100,menubar=yes'); player4.focus();
function cards4() { return "<title>Player 4 Cards</title><br><font color=white>"+card6+"<BR>"+card7+"</font>"; }
player3 = open('javascript:opener.cards3()', 'player3', 'left=10,width=200,height=100,menubar=yes'); player3.focus();
function cards3() { return "<title>Player 3 Cards</title><br><font color=white>"+card4+"<BR>"+card5+"</font>"; }
player2 = open('javascript:opener.cards2()', 'player2', 'left=10,width=200,height=100,menubar=yes'); player2.focus();
function cards2() { return "<title>Player 2 Cards</title><br><font color=white>"+card2+"<BR>"+card3+"</font>"; }
player1 = open('javascript:opener.cards1()', 'player1', 'left=10,width=200,height=100,menubar=yes'); player1.focus();
function cards1() { return "<title>Player 1 Cards</title><br><font color=white>"+card0+"<BR>"+card1+"</font>"; }
but what about incrementing the player #
Mick White wrote: dmanklein wrote:
I would like to add multiple loop statements to the following to shorten the code:
var card0 = asLucky[0]; var card1 = asLucky[1]; var card2 = asLucky[2]; etc for(var i=0;i<16;1++){eval("var card"+i+"="+asLucky[i];)}
eval() is almost never needed:
for (var i = 0; i < asLucky.length; i++) {
window["card" + i] = asLucky[i];
}
But why bother? Just use asLucky[n] where you use card...n
Of course. If you have values stored in an array, there is almost no reason to
assign each individual array value to another variable unless you are planning
on manipulating that new variable in a way that would change the value in the
array in a way you do not wish it to be changed. In this case, the variables
are simply being output, there's no reason to assign the array values to
another set of variables.
--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq
dmanklein wrote: but what about incrementing the player #
It would help if you created an Array, or an Object to contain player
and card info.
I would start from scratch, though.
A URL perhaps?
Mick This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jo Vermeulen |
last post by:
Hello,
I was wondering if it's possible to add a condition to the enhanced for
loop. This is an example of an enhanced for loop:
LinkedList<MyClass> children = new LinkedList<MyClass>();...
|
by: Rhamphoryncus |
last post by:
First a bit about myself. I've been programming in python several
years now, and I've got several more years before that with C. I've
got a lot of interest in the more theoretical stuff (language...
|
by: Paul M. |
last post by:
Hi,
I am trying to add a dataset to a list box on an asp .net page, the
query results in about 20 rows coming back when I run it in access but when
I loop through the dataset adding each records...
|
by: lancevictor |
last post by:
I'm learning javascript, and toward that end, I am recreating a page
"my way". The original page: http://stenbergcollege.com and the one
that I'm creating:...
|
by: 6thirty |
last post by:
Hi,
I've created a stocktaking database using Access XP. This is indexed by two
fields - part number and shelf location.
I am currently inputting all the data via a form. When I have entered a...
|
by: Niels Jensen |
last post by:
I have the following code in a Sub which is called by a do loop statement for
each line starting with unit info in an e-mail based game that I play. I'm
exctracting the keywords from the text and...
|
by: Ben R. |
last post by:
In an article I was reading
(http://www.ftponline.com/vsm/2005_06/magazine/columns/desktopdeveloper/),
I read the following:
"The ending condition of a VB.NET for loop is evaluated only once,...
|
by: David M. Synck |
last post by:
Hi all,
I am fairly new to Python and trying to figure out a syntax error
concerning lists and iteration through the same. What I am trying to do is
sum a list of float values and store the sum...
|
by: Justin Fancy |
last post by:
Hi everyone,
I need some help. I'm placing text files into a created database using
vb.Net. The problem is that, i need two seperate sql statements to add
both files because they are in...
|
by: Kosmos |
last post by:
I have traveled the world and the seven seas and I have yet to come up with an answer to this question....
So I'm adding an attachment to an email from access...
The following is the code:
...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |