Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 01-06-2011, 07:38 AM random input
Novice Talker

Posts: 6
Trades: 0
Hi there,

This is a code how to make random input in imacros for 1 input{{fruit}} I need to know how can I make 3 inputs random like {{fruit2}} {{fruit3}} {{fruit3}}

PHP Code:
myfruits = new Array();
myfruits.push("Strawberry");
myfruits.push("Banana");
myfruits.push("Kiwi");
myfruits.push("Orange");
myfruits.push("Mango");

for(
i=0;i<10;i++) 
{
   
randomint Math.floor(Math.random()*myfruits.length);
   

    
iimSet("fruit",myfruits[randomint]); 

joker12 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-07-2011, 02:23 PM Re: random input
Super Spam Talker

Posts: 879
Name: Paul W
Trades: 0
Assuning 1,2 and 3 have to be different: set fruit2 = fruit and then loop while fruit2 == fruit, calling the randomiser. Set fruit3 = fruit and then loop while fruit3 == fruit OR frui3 == fruit2
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE


*** New:
Please login or register to view this content. Registration is FREE
PaulW is online now
Reply With Quote
View Public Profile
 
Old 01-08-2011, 10:23 AM Re: random input
Novice Talker

Posts: 6
Trades: 0
Hi paul,
I don`t know how this make can you make a example

Thanks.
joker12 is offline
Reply With Quote
View Public Profile
 
Old 01-10-2011, 04:05 PM Re: random input
Novice Talker

Posts: 6
Trades: 0
any help please
joker12 is offline
Reply With Quote
View Public Profile
 
Old 01-14-2011, 10:22 PM Re: random input
Super Spam Talker

Posts: 879
Name: Paul W
Trades: 0
http://www.quackit.com/javascript/tu...while_loop.cfm
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE


*** New:
Please login or register to view this content. Registration is FREE
PaulW is online now
Reply With Quote
View Public Profile
 
Old 01-16-2011, 10:45 AM Re: random input
Novice Talker

Posts: 6
Trades: 0
thank you Paul but on imacros not work
joker12 is offline
Reply With Quote
View Public Profile
 
Old 01-16-2011, 11:28 AM Re: random input
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Code:
myfruits = new Array();
myfruits.push("Strawberry");
myfruits.push("Banana");
myfruits.push("Kiwi");
myfruits.push("Orange");
myfruits.push("Mango");

function getFruit() {
for(i=0;i<10;i++) 
{
   randomint = Math.floor(Math.random()*myfruits.length);
return  myfruits[randomint]'
}
to use -
HTML Code:
response.write(getFruit()):
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-16-2011, 01:19 PM Re: random input
Novice Talker

Posts: 6
Trades: 0
Look what I use :

Code:
myfruits = new Array();
myfruits.push("Strawberry");
myfruits.push("Banana");
myfruits.push("Kiwi");
myfruits.push("Orange");
myfruits.push("Mango");


function getFruit() {
for(i=0;i<10;i++) 
{
   randomint = Math.floor(Math.random()*myfruits.length);
return  myfruits[randomint]'

   
   iimSet("fruit",myfruits[randomint]); //in the macro you can access the random fruit through {{fruit}} much like you would {{!VAR1}}

   iimPlay("fruit.iim");

}
and I have error SyntaxError: return not in function, line: 19
joker12 is offline
Reply With Quote
View Public Profile
 
Old 01-16-2011, 01:45 PM Re: random input
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
messed up the brackets

Code:
   randomint = Math.floor(Math.random()*myfruits.length);
}
return  myfruits[randomint];
}
Should really test before posting
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-16-2011, 02:53 PM Re: random input
Novice Talker

Posts: 6
Trades: 0
Sorry, not work she give me __undefined__
fruit.iim
Code:
TAG POS=1 TYPE=INPUT:TEXT FORM=* ATTR=ID:* CONTENT={{fruit}}
TAG POS=2 TYPE=INPUT:TEXT FORM=* ATTR=ID:* CONTENT={{fruit2}}
fruit.js
Code:
var myfruits = new Array();
myfruits = new Array();
myfruits.push("Strawberry");
myfruits.push("Banana");
myfruits.push("Kiwi");
myfruits.push("Orange");
myfruits.push("Mango");


function getFruit() {
for(i=0;i<10;i++) 
{
    randomint = Math.floor(Math.random()*myfruits.length);
}
return  myfruits[randomint];

   
   iimSet("fruit",myfruits[randomint]); //in the macro you can access the random fruit through {{fruit}} much like you would {{!VAR1}}

   iimPlay("fruit.iim");

}
joker12 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to random input
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.07000 seconds with 12 queries