Radio Button change POS variable via CSV

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.
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
davek96818
Posts: 3
Joined: Thu Jan 28, 2021 1:31 am

Radio Button change POS variable via CSV

Post by davek96818 » Thu Apr 22, 2021 3:54 am

I'm pretty new to iMacros. I've looked through the forums and haven't found the answer and hope somebody can help me. The web page I'm trying to populate looks like this:
yesbutton.jpg
yesbutton.jpg (9.17 KiB) Viewed 2838 times
I'm trying to have a CVS file loop through and either select yes or no for each item. The code generated by iMacros looks like this:

TAG POS=1 TYPE=INPUT:RADIO ATTR=NAME:SearchParams.EPISSN
TAG POS=2 TYPE=INPUT:RADIO ATTR=NAME:SearchParams.EPISuffix
TAG POS=1 TYPE=INPUT:RADIO ATTR=NAME:SearchParams.EPIDateAsOf

To generate it I clicked Yes, No, Yes on the buttons. I notice that if yes is clicked the POS=1 comes up and if no is clicked the POS=2 comes up. The overall page I'm trying to automated as about 50 of these buttons. Usually with other types there is a CONTENT={{col1}} or similiar to pull from the CSV file, however in this cause how do I get the POS to go 1 or 2 for yes or no? Or is there some other type of code I need to write to accomplish this.

A little more info if I click both yes and no on say the first items (social security number) this shows up:

TAG POS=1 TYPE=INPUT:RADIO ATTR=NAME:SearchParams.EPISSN
TAG POS=2 TYPE=INPUT:RADIO ATTR=NAME:SearchParams.EPISSN

Any help is greatly appreciated. Thanks.

iMacros: 12.6.0.190
Browser: iMacros native broswer
Windows 10
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Radio Button change POS variable via CSV

Post by chivracq » Thu Apr 22, 2021 2:26 pm

davek96818 wrote:
Thu Apr 22, 2021 3:54 am
I'm pretty new to iMacros. I've looked through the forums and haven't found the answer and hope somebody can help me. The web page I'm trying to populate looks like this:

yesbutton.jpg

I'm trying to have a CVS file loop through and either select yes or no for each item. The code generated by iMacros looks like this:

Code: Select all

TAG POS=1 TYPE=INPUT:RADIO ATTR=NAME:SearchParams.EPISSN
TAG POS=2 TYPE=INPUT:RADIO ATTR=NAME:SearchParams.EPISuffix
TAG POS=1 TYPE=INPUT:RADIO ATTR=NAME:SearchParams.EPIDateAsOf
To generate it I clicked Yes, No, Yes on the buttons. I notice that if yes is clicked the POS=1 comes up and if no is clicked the POS=2 comes up. The overall page I'm trying to automated as about 50 of these buttons. Usually with other types there is a CONTENT={{col1}} or similiar to pull from the CSV file, however in this cause how do I get the POS to go 1 or 2 for yes or no? Or is there some other type of code I need to write to accomplish this.

A little more info if I click both yes and no on say the first items (social security number) this shows up:

Code: Select all

TAG POS=1 TYPE=INPUT:RADIO ATTR=NAME:SearchParams.EPISSN
TAG POS=2 TYPE=INPUT:RADIO ATTR=NAME:SearchParams.EPISSN
Any help is greatly appreciated. Thanks.

Code: Select all

iMacros: 12.6.0.190
Browser: iMacros native broswer
Windows 10

Well, if you store "1"/"2" in your 'Col_n' (for "Yes"/"No") for each RB, you can use '{{!COLn}}' for "POS=n"... :idea:
=> For example, if your 3 RB's are stored in Cols 'Col_[5-7]', that would give:

Code: Select all

TAG POS={{!COL5}} TYPE=INPUT:RADIO ATTR=NAME:SearchParams.EPISSN
TAG POS={{!COL6}} TYPE=INPUT:RADIO ATTR=NAME:SearchParams.EPISuffix
TAG POS={{!COL7}} TYPE=INPUT:RADIO ATTR=NAME:SearchParams.EPIDateAsOf
>

If you prefer to store "Yes"/"No" in the '.CSV', it would be possible to use 'EVAL()' before each each 'TAG' Statement to "convert" that "Yes/No" into "1/2", like for example:

Code: Select all

'RB_SSN (Col_5):
SET RB_SSN EVAL("var c='{{!COL5}}'; var z; if(c=='Yes'){z=1;} else{z=2;}; z;")
TAG POS={{RB_SSN}} TYPE=INPUT:RADIO ATTR=NAME:SearchParams.EPISSN
'>
'RB_Suffix (Col_6):
SET RB_Suffix EVAL("var c='{{!COL6}}'; var z; if(c=='Yes'){z=1;} else{z=2;}; z;")
TAG POS={{RB_Suffix}} TYPE=INPUT:RADIO ATTR=NAME:SearchParams.EPISuffix
'>
'RB_As_Of_Date (Col_7):
SET RB_As_Of_Date EVAL("var c='{{!COL7}}'; var z; if(c=='Yes'){z=1;} else{z=2;}; z;")
TAG POS={{RB_As_Of_Date}} TYPE=INPUT:RADIO ATTR=NAME:SearchParams.EPIDateAsOf
...But hum, a little bit cumbersome though, I would think..., and hum, you mention that you have 50 of those RB's, ah-ah...! :shock: :oops:

>

Another "Solution" would be to use the 'VALUE' Param for each RB... :idea:
You'll need to check the HTML Source of the Page (I can't do that for you from a Screenshot, ah-ah...!), and the "Yes/No" will be defined as "1/2" also...
Although "Yes/No", and even "2/1" or "No/Yes" would be possible...!
Then that would give:

Code: Select all

TAG POS=1 TYPE=INPUT:RADIO ATTR=NAME:SearchParams.EPISSN&&VALUE:{{!COL5}}
TAG POS=1 TYPE=INPUT:RADIO ATTR=NAME:SearchParams.EPISuffix&&VALUE:{{!COL6}}
TAG POS=1 TYPE=INPUT:RADIO ATTR=NAME:SearchParams.EPIDateAsOf&&VALUE:{{!COL7}}
(And yep...!, it will be "POS=1" for all RB's, the 'VALUE' Param will handle the Tagging/Selecting...)

>

If all RB's are called "SearchParams.EPI[xxx]", it is also possible to make your Script a little bit more "generic", like in:

Code: Select all

TAG POS=1 TYPE=INPUT:RADIO ATTR=NAME:SearchParams.EPI*&&VALUE:{{!COL5}}
TAG POS=2 TYPE=INPUT:RADIO ATTR=NAME:SearchParams.EPI*&&VALUE:{{!COL6}}
TAG POS=3 TYPE=INPUT:RADIO ATTR=NAME:SearchParams.EPI*&&VALUE:{{!COL7}}
... But you need to increment the 'POS=n' for each RB...

>

In all Cases, you'll have to hard-code the '{{!COLn}}', and that 50 times for all 50 RB's, ah-ah...!
If you were using iMacros for FF, there is a nice Trick that allows to read one complete Row from the DataSource in just 1 Statement, then it would be possible to make the 'TAG' Statement completely generic that you simply can Copy&Paste the exact same Line of Code (well, 2 or 3 Lines actually) 50 times, but that Trick is not supported in other Browsers than FF... :(

... Well, not directly, but I can still think of a Workaround for iMB, and I guess that could be worth for 50 RB's...
Then OK, let's go...!: :twisted:

Alright, I was using 'Col_[5-7]' until now for only 3 RB's like in your Code Example, now we are talking about 50 RB's, => stored in your '.CSV' in Cols [5-54], if I can count correctly, ah-ah...!! :P

=> Then that will give stg like...:

Code: Select all

'Prefetch all 50 Values for all 50 RadioButtons from the '.CSV' (Cols [5-54]):
SET RB_Values _{{!COL5}}_{{!COL6}}_{{!COL7}}_{{!COL8}}_{{!COL9}}_{{!COL10}}_{{!COL11}}_{{!COL12}}_{{!COL13}}_{{!COL14}}
ADD RB_Values _{{!COL15}}_{{!COL16}}_{{!COL17}}_{{!COL18}}_{{!COL19}}_{{!COL20}}_{{!COL21}}_{{!COL22}}_{{!COL23}}_{{!COL24}}
ADD RB_Values _{{!COL25}}_{{!COL26}}_{{!COL27}}_{{!COL28}}_{{!COL29}}_{{!COL30}}_{{!COL31}}_{{!COL32}}_{{!COL33}}_{{!COL34}}
ADD RB_Values _{{!COL35}}_{{!COL36}}_{{!COL37}}_{{!COL38}}_{{!COL39}}_{{!COL40}}_{{!COL41}}_{{!COL42}}_{{!COL43}}_{{!COL44}}
ADD RB_Values _{{!COL45}}_{{!COL46}}_{{!COL47}}_{{!COL48}}_{{!COL49}}_{{!COL50}}_{{!COL51}}_{{!COL52}}_{{!COL53}}_{{!COL54}}
'>
SET RB_Index 0

'Fill in all 50 RB's:
'*********************
ADD RB_Index 1
SET RB_Value EVAL("var rbv='{{RB_Values}}', rbi='{{RB_Index}}', x,y,z; x=rbv.split('_'); z=x[rbi]; z;")
TAG POS={{RB_Index}} TYPE=INPUT:RADIO ATTR=NAME:SearchParams.EPI*&&VALUE:{{RB_Value}}
'>
ADD RB_Index 1
SET RB_Value EVAL("var rbv='{{RB_Values}}', rbi='{{RB_Index}}', x,y,z; x=rbv.split('_'); z=x[rbi]; z;")
TAG POS={{RB_Index}} TYPE=INPUT:RADIO ATTR=NAME:SearchParams.EPI*&&VALUE:{{RB_Value}}
'>
ADD RB_Index 1
SET RB_Value EVAL("var rbv='{{RB_Values}}', rbi='{{RB_Index}}', x,y,z; x=rbv.split('_'); z=x[rbi]; z;")
TAG POS={{RB_Index}} TYPE=INPUT:RADIO ATTR=NAME:SearchParams.EPI*&&VALUE:{{RB_Value}}
'>
ADD RB_Index 1
SET RB_Value EVAL("var rbv='{{RB_Values}}', rbi='{{RB_Index}}', x,y,z; x=rbv.split('_'); z=x[rbi]; z;")
TAG POS={{RB_Index}} TYPE=INPUT:RADIO ATTR=NAME:SearchParams.EPI*&&VALUE:{{RB_Value}}
'>
'... etc ... You Copy&Paste 50 times that same Block of Code...!
'>
ADD RB_Index 1
SET RB_Value EVAL("var rbv='{{RB_Values}}', rbi='{{RB_Index}}', x,y,z; x=rbv.split('_'); z=x[rbi]; z;")
TAG POS={{RB_Index}} TYPE=INPUT:RADIO ATTR=NAME:SearchParams.EPI*&&VALUE:{{RB_Value}}
Not tested, there could always be some Typo(s) "somewhere", but I guess/hope, you'll understand the Principle... :twisted: :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...
davek96818
Posts: 3
Joined: Thu Jan 28, 2021 1:31 am

Re: Radio Button change POS variable via CSV

Post by davek96818 » Fri Apr 23, 2021 3:57 am

Chivracq thanks for your quick reply packed with information. Based on what you said I was able to accomplish what I needed and also got a better understanding of how to use iMacros. Much appreciated.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Radio Button change POS variable via CSV

Post by chivracq » Fri Apr 23, 2021 1:13 pm

davek96818 wrote:
Fri Apr 23, 2021 3:57 am
Chivracq thanks for your quick reply packed with information. Based on what you said I was able to accomplish what I needed and also got a better understanding of how to use iMacros. Much appreciated.

OK, good to hear, and Thanks for the Follow-up..., but hum..., I gave you 5 different Techniques/Implementations, could you mention which one did you choose...?
... And maybe post your final/working Script...? (... based on (the) 3 RB's like you had done in your OP, we don't need the 50 RB's, ah-ah...!)
=> ... As that would also be useful for other Users... :idea:
- (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...
davek96818
Posts: 3
Joined: Thu Jan 28, 2021 1:31 am

Re: Radio Button change POS variable via CSV

Post by davek96818 » Tue Apr 27, 2021 2:02 am

I used the

Well, if you store "1"/"2" in your 'Col_n' (for "Yes"/"No") for each RB, you can use '{{!COLn}}' for "POS=n"... :idea:

solution. Since the website it run by an outside entity I didn't the ability to alter the code. Also the converting 1/2 to yes/no just added to many lines of code. I decided much easier to control what goes into the CSV file. We can pretty easily alter are database extract to CSV to code the 1/2. I'm pretty sure I will use the same technique from some drop down boxes I will be looking into next.
Post Reply