Sign in to follow this  
Followers 0
supadodger

click random radio box

8 posts in this topic

the original code was

$oInputs = _IETagNameGetCollection($oIE, "input")
    For $oInput In $oInputs
        If $oInput.type = "checkbox" Then $oInput.checked = True
    NextoÝ÷ Ú'!jxv+m¡«­¢+ØÀÌØí½%¹ÁÕÑÌô}%Q9µÑ
½±±Ñ¥½¸ ÀÌØí½%°ÅÕ½Ðí¥¹ÁÕÐÅÕ½Ðì¤(%½ÈÀÌØí½%¹ÁÕÐ%¸ÀÌØí½%¹ÁÕÑÌ($%%ÀÌØí½%¹ÁÕйÑåÁôÅÕ½ÐíÉ¥¼ÅÕ½ÐìQ¡¸ÀÌØí½%¹ÁÕй¡­ôQÉÕ(%9á

which makes it check every radio box.

so it really just ends up on the last radio box.

what would i change to just randomly click any of the radio boxes?

Share this post


Link to post
Share on other sites



$oInputs = _IETagNameGetCollection($oIE, "input")

For $oInput In $oInputs

$true = random(0,1,1)

If $true = 1 then

If $oInput.type = "radio" Then

$oInput.checked = True

exitloop

endif

endif

Next

?


Giggity

Share this post


Link to post
Share on other sites

$oInputs = _IETagNameGetCollection($oIE, "input")

For $oInput In $oInputs

$true = random(0,1,1)

If $true = 1 then

If $oInput.type = "radio" Then

$oInput.checked = True

exitloop

endif

endif

Next

?

doesnt that just check or uncheck the first box?

i want to randomly select 1 of 28 radio boxes

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

well it would randomly select one or zero, if it is one it will check that radio and exit the loop.

Edit: I don't think it would ever check radio 28...

Edited by youknowwho4eva

Giggity

Share this post


Link to post
Share on other sites

well it would randomly select one or zero, if it is one it will check that radio and exit the loop.

Edit: I don't think it would ever check radio 28...

i know.

what you have it only checks the first one or none.

thanks for trying though.

Share this post


Link to post
Share on other sites

You could also run through the inputs once just to get a count, then use random to pick one of them, then run through them again and if it is the right count as the random that you did then set that one to checked.


[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites

Not tested obviously.. but this gives you the idea..

Dim $count, $rnd
$oInputs = _IETagNameGetCollection($oIE, "input")
$count = 0
For $oInput In $oInputs
    If $oInput.type = "radio" Then $count += 1
Next

If $count > 1 Then $rnd = Random(1, $count, 1)

$oInputs = _IETagNameGetCollection($oIE, "input")
$count = 0
For $oInput In $oInputs
    If $oInput.type = "radio" Then $count += 1
    If $count = $rnd Then $oInput.checked = True
Next

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites

Not tested obviously.. but this gives you the idea..

Dim $count, $rnd
$oInputs = _IETagNameGetCollection($oIE, "input")
$count = 0
For $oInput In $oInputs
    If $oInput.type = "radio" Then $count += 1
Next

If $count > 1 Then $rnd = Random(1, $count, 1)

$oInputs = _IETagNameGetCollection($oIE, "input")
$count = 0
For $oInput In $oInputs
    If $oInput.type = "radio" Then $count += 1
    If $count = $rnd Then $oInput.checked = True
Next

i was looking in the right section of the help file at least.

i was just trying differnt things out and trying to figure out what everything means.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0