Check if radio button is selected or not

Discussions and Tech Support specific to the iMacros Firefox add-on.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
techimac
Posts: 482
Joined: Fri Feb 20, 2015 9:27 pm

Check if radio button is selected or not

Post by techimac » Tue Jan 23, 2018 12:21 am

how to check if any radio button from a group is selected or not?

example code

Code: Select all

<form>
	<p><input type="radio" name="R1" value="V1" ></p>
	<p><input type="radio" name="R1" value="V2"></p>
</form>
Firefox 47
iMacros 8.9.7
Windows 8.1
Available for custom iim, javascript iMacros scripts
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Check if radio button is selected or not

Post by chivracq » Tue Jan 23, 2018 3:03 am

techimac wrote:how to check if any radio button from a group is selected or not?

example code

Code: Select all

<form>
	<p><input type="radio" name="R1" value="V1" ></p>
	<p><input type="radio" name="R1" value="V2"></p>
</form>
Firefox 47
iMacros 8.9.7
Windows 8.1
Post a Site with some RB for me to do any Testing... :idea:
Hum..., and it shouldn't be very difficult to check/test...?, what is the Pb...?, what have you tried...? You are not a Newbie...! (Hum, I don't help Newbies who don't try anything either, ah-ah...!) :twisted:

Your 'Example" sucks a bit (like any "Fake" Example without real URL btw...), because of the extra Space for 'V1' and you don't mention if any Option is already selected or not...
I think I use that Functionality "somewhere" in one of my Scripts, but I think that's in some Script of mine about 8000 Lines long, I don't know where exactly anymore, is quicker if you can find a Site with some RB...

Hum/Grrr...!, and your Thread has nothing specific to iMacros for FF :roll: , correct Sub-Forum was the 'General' one..., hum or the 'Data Extraction' one... (No need to duplicate now of course...!)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
techimac
Posts: 482
Joined: Fri Feb 20, 2015 9:27 pm

Re: Check if radio button is selected or not

Post by techimac » Tue Jan 23, 2018 6:51 am

I got the solution for checking particular radio button
need a way to find if any radio button is selected or not in a group

I tried ATTR=CHECKED:CHECKED EXTRACT=TXT
but it didn't worked.
Available for custom iim, javascript iMacros scripts
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Check if radio button is selected or not

Post by chivracq » Tue Jan 23, 2018 7:19 pm

techimac wrote:I got the solution for checking particular radio button
need a way to find if any radio button is selected or not in a group

I tried ATTR=CHECKED:CHECKED EXTRACT=TXT
but it didn't worked.
Yeah, I don't know, you didn't post a "concrete" URL, so I had a look at the Page on the Forum when posting a Reply or a Quote, with the 'Post icon' RB's, the first one (= "None") is automatically selected when the Page is loaded for the first time, and it has indeed some "checked="checked"" Attribute, but even after changing the RB Selection to another Icon, and the Selection remains after a Refresh of the Page, but it's always (and only) the 'None' Icon that still has this 'checked' Attribute while it is actually a different Icon which is selected... :?

I don't remember encountering any "heavy" Difficulty when I implemented some similar Functionality in one of my Scripts (but hum, several years ago), so I'm not sure what's the Difference, or maybe it was about Checkbox Elements, I don't know...

I hope you'll post the/your Solution if you manage to solve it, I'll be interested...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
techimac
Posts: 482
Joined: Fri Feb 20, 2015 9:27 pm

Re: Check if radio button is selected or not

Post by techimac » Tue Jan 23, 2018 8:47 pm

ATTR=CHECKED:CHECKED EXTRACT=TXT
element was not available
once I have the solution or found proper HTML code to find solution, I will share
Available for custom iim, javascript iMacros scripts
techimac
Posts: 482
Joined: Fri Feb 20, 2015 9:27 pm

Re: Check if radio button is selected or not

Post by techimac » Tue Jan 23, 2018 8:48 pm

I can give you code for checking single radio button state
Available for custom iim, javascript iMacros scripts
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Check if radio button is selected or not

Post by chivracq » Tue Jan 23, 2018 9:20 pm

techimac wrote:ATTR=CHECKED:CHECKED EXTRACT=TXT
element was not available
once I have the solution or found proper HTML code to find solution, I will share
OK...
techimac wrote:I can give you code for checking single radio button state
Yeah, sure..., that can always be useful for other Users and that might give me some "Ideas", ah-ah...! :wink:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
techimac
Posts: 482
Joined: Fri Feb 20, 2015 9:27 pm

Re: Check if radio button is selected or not

Post by techimac » Tue Jan 23, 2018 9:49 pm

TAG POS=1 TYPE=............ EXTRACT=CHECKED

"YES" if checked and "NO" if not checked
Available for custom iim, javascript iMacros scripts
techimac
Posts: 482
Joined: Fri Feb 20, 2015 9:27 pm

Re: Check if radio button is selected or not

Post by techimac » Tue Jan 23, 2018 9:51 pm

Available for custom iim, javascript iMacros scripts
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Check if radio button is selected or not

Post by chivracq » Tue Jan 23, 2018 11:22 pm

techimac wrote:TAG POS=1 TYPE=............ EXTRACT=CHECKED

"YES" if checked and "NO" if not checked
Oh..., yes of course, "EXTRACT=CHECKED"...!!

OK, then I remember my own Script, that's exactly what I was using as well indeed, as it is documented in the Wiki for 'TAG' + 'EXTRACT', and I remember thinking there was a mistake in the Wiki about the "true"/"false" instead of "YES"/"NO", ah-ah...!

Well, then, if you don't know in advance which RB is checked, you simply need to extract them all and using 'EVAL()' + 'if/else' or 'CASE' to find out which one is selected, that's not very complicated...
Or you store all YES/NO Values in a String or Array and using 'split()' x2, first on "YES" and then on "NO", then the Length of the 2nd Array gives you the Position of which RB is selected...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
techimac
Posts: 482
Joined: Fri Feb 20, 2015 9:27 pm

Re: Check if radio button is selected or not

Post by techimac » Tue Jan 23, 2018 11:27 pm

chivracq wrote:
techimac wrote:TAG POS=1 TYPE=............ EXTRACT=CHECKED

Well, then, if you don't know in advance which RB is checked, you simply need to extract them all and using 'EVAL()' + 'if/else' or 'CASE' to find out which one is selected, that's not very complicated...
Or you store all YES/NO Values in a String or Array and using 'split()' x2, first on "YES" and then on "NO", then the Length of the 2nd Array gives you the Position of which RB is selected...
I have written javascript code for that
its very simple
Available for custom iim, javascript iMacros scripts
techimac
Posts: 482
Joined: Fri Feb 20, 2015 9:27 pm

Re: Check if radio button is selected or not

Post by techimac » Tue Jan 23, 2018 11:29 pm

I was hoping for some HTML tag value for checked radio button in a group
then it will be just one line instead of looping through radio buttons
Available for custom iim, javascript iMacros scripts
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Check if radio button is selected or not

Post by chivracq » Tue Jan 23, 2018 11:47 pm

Well, then share your Code if you've already written it, that can always be useful for other Users... (And your Solution sounds simpler anyway then all 3 or 4 I have in mind...)

I didn't see indeed anything in the HTML Source Code telling "directly" which RB is selected, I don't really understand how the 'EXTRACT=CHECKED' is able to return if a RB is selected or not, but it works indeed, ah-ah...!
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Post Reply