[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

another stupid question: filling out webforms

stefan s.

11/26/2003 3:08:00 PM

hi

i´d like to fill out a html webform with ruby with randomly generated
values. an example:

- the form is @ www.mypage.com/webform.html
- there´s one field in this form: "zip" (<input type="text" name="zip">)
- i should be filled out with a random text-value smaller than 8 characters
by the ruby script

please help me!

p.s. excuse my bad english :)


3 Answers

Rodrigo Bermejo

11/26/2003 3:51:00 PM

0

Try this...


def random_text

letters = ("a".."z").to_a

letters.each_index do | l |

r = rand(letters.length - 1);

letters[l],letters[r] =letters[r],letters[l]

end

string = letters[0,rand(8)].to_s

if string.empty?
random_text
else
return string
end

end

print %^<input type="text" name="zip" value=#{random_text}>^



it is what you are looking for ?





stefan s. wrote:

>hi
>
>i´d like to fill out a html webform with ruby with randomly generated
>values. an example:
>
>- the form is @ www.mypage.com/webform.html
>- there´s one field in this form: "zip" (<input type="text" name="zip">)
>- i should be filled out with a random text-value smaller than 8 characters
>by the ruby script
>
>please help me!
>
>p.s. excuse my bad english :)
>
>
>
>



Ara.T.Howard

11/26/2003 5:01:00 PM

0

stefan s.

11/26/2003 6:26:00 PM

0

hi

thx for helping me!


"Bermejo, Rodrigo" <rodrigo.bermejo@ps.ge.com> schrieb im Newsbeitrag
news:3FC4CAE1.3030308@ps.ge.com...
> Try this...
>
>
> def random_text
>
> letters = ("a".."z").to_a
>
> letters.each_index do | l |
>
> r = rand(letters.length - 1);
>
> letters[l],letters[r] =letters[r],letters[l]
>
> end
>
> string = letters[0,rand(8)].to_s
>
> if string.empty?
> random_text
> else
> return string
> end
>
> end
>
> print %^<input type="text" name="zip" value=#{random_text}>^
>
>
>
> it is what you are looking for ?
>
>
>
>
>
> stefan s. wrote:
>
> >hi
> >
> >i´d like to fill out a html webform with ruby with randomly generated
> >values. an example:
> >
> >- the form is @ www.mypage.com/webform.html
> >- there´s one field in this form: "zip" (<input type="text" name="zip">)
> >- i should be filled out with a random text-value smaller than 8
characters
> >by the ruby script
> >
> >please help me!
> >
> >p.s. excuse my bad english :)
> >
> >
> >
> >
>
>
>