473,395 Members | 1,348 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

random function

I don't know if this is easy or not, I have no clue on how to start it.

I have Seven different states.
I will be having a form with 7 textboxes, and I will enter 7 different
states each time in the textbox.
When I click on the button, it would call a function
the function would output :
6 different combinations of 3 states. So I would have 1-6 and for each
would list three states I entered in the textboxes.

Thanks alot!
Jul 23 '05 #1
2 1486
Samir wrote on 10 sep 2004 in comp.lang.javascript:
I have Seven different states.
you mean like:

1 awake
2 asleep
3 programming
4 working
5 in love
6 hungry
7 dead

?
I will be having a form with 7 textboxes, and I will enter 7 different
states each time in the textbox.
When I click on the button, it would call a function
the function would output :
6 different combinations of 3 states. So I would have 1-6 and for each
would list three states I entered in the textboxes.


like:

1 123
2 124
3 125
4 126
5 134
6 132

?

You cannot be awake and asleep at once.

Seems sily to me, but probably I misunderstand you.
Or is it "states" like in "baseball cards"?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)

Jul 23 '05 #2
Lee
Samir said:

I don't know if this is easy or not, I have no clue on how to start it.

I have Seven different states.
I will be having a form with 7 textboxes, and I will enter 7 different
states each time in the textbox.
When I click on the button, it would call a function
the function would output :
6 different combinations of 3 states. So I would have 1-6 and for each
would list three states I entered in the textboxes.

This sounds a bit like a class assignment to me, but I'm
avoiding starting my real work, so I'll bite:

The way to start it is to state the problem more precisely.

As I understand it, you're looking for a function that will
take as input the values of seven text fields, and will
generate six different combinations of those seven values
taken three at a time.

1. It's not clear how you want these combinations to be
presented on your page.

2. Since there are 35 possible combinations of 7 items
taken 3 at a time, it's not clear whether you want to
choose six of them at random, or if it's ok to use the
same pattern each time.

If it doesn't need to be random, here's a trivial solution in
which combination #n contains the three sequential inputs
beginning with input #n (looping back to the beginning at the
end of the list of inputs.
So if the "states" are "alpha" "beta" "gamma" "delta" ..., the
first combination will be "alpha beta gamma", the second will
be "beta gamma delta", etc:
<html>
<head>
<title>Combinations</title>
<script type="text/javascript">
function combine(inArray,outArray){
for(i=0;i<6;i++){
outArray[i].value="";
var j=i;
for(k=0;k<3;k++){
outArray[i].value+=inArray[j++].value+" ";
j%=6;
}
}
}
</script>
</head>
<body>
<form>
<input name="state" value="a" size="4">
<input name="state" value="b" size="4">
<input name="state" value="c" size="4">
<input name="state" value="d" size="4">
<input name="state" value="e" size="4">
<input name="state" value="f" size="4">
<input name="state" value="g" size="4">
<br>
<input type="button"
value="combine"
onclick="combine(this.form.state,this.form.com)">
<hr>
<input name="com" size="8"><input name="com" size="8">
<input name="com" size="8"><input name="com" size="8">
<input name="com" size="8"><input name="com" size="8">
</form>
</body>
</html>

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
by: JNY | last post by:
I am using random to generate random numbers, thus: int x,y; for (y = 0;y < 5;y++) { x = random(50); cout << x; }
3
by: TaTonka | last post by:
hi! how can i manage it (html or jscript with css) that everytime a user loads or refreshes a page, the page has a new bgcolor. i want to put it in a single file, so that all my pages have the...
4
by: Greg Strong | last post by:
Hello All, Is it possible to create multiple random numbers in a query where there are numerous records? I've created a custom function. When I use it in a query it creates the same random...
13
by: Jon Agiato | last post by:
Hello, I am sure this problem is easy to spot but I have been at this project all day and the frustration has finally overcome me. I am using this function in order to produce a standard normal...
10
by: Leon | last post by:
I know by default the random number generator use the time, but what is the best seed I can used in my web application? The Program generate 6 unique random numbers and load each of them in a...
3
by: JoelPJustice | last post by:
I am working through a VBA book by myself to help and try and improve my skills. However, the book does not give you solutions to certain problems. I have worked through this problem up until bullet...
12
by: Pascal | last post by:
hello and soory for my english here is the query :"how to split a string in a random way" I try my first shot in vb 2005 express and would like to split a number in several pieces in a random way...
1
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I generate a random integer from 1 to N?...
3
by: tshad | last post by:
I have a page that I am getting a username and password as a random number (2 letters, one number and 4 more letters) I have 2 functions I call: *************************************************...
0
by: UmeIsmail | last post by:
i am trying to implement GP , and have random initialization in arraylist , the code works fine in debug mode , but when i run it without debugging, all trees come out to be same , if i use message...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
0
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
tracyyun
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.