Javascript Grid Selection and data input

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
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
eagleb1
Posts: 9
Joined: Fri Oct 18, 2019 12:35 am

Javascript Grid Selection and data input

Post by eagleb1 » Fri Oct 18, 2019 7:37 pm

How is best way to find and update data in a dynamic javascript grid. I am using lastest iMacros Pro and iMacros browser. See below for snippet of website dynamic Javascript grid and code. Thanks

<td role="gridcell" id="g-01v2-8843" class="TDC g-01y2_0 FieldEnabled Field TCRight CellQuantity CellEditable g-01v2 CellEditing" data-maxlength="30" headers="g-01v2-CH" style="padding: 0px;">
<div class="DTC" style="padding: 0px;">
<span id="c_g-01v2-8843" class="DCC">
<input type="text" spellcheck="false" style="font-size: inherit; text-align: right; text-transform: none; width: 98px; height: 31px;" maxlength="30" class="TDC g-01y2_0 FieldEnabled Field TCRight CellQuantity CellEditable g-01v2 CellEditing">
</span>
<div id="indicator_g-01v2-8843" class="FI FieldIndicator"></div>
</div>
</td>
JavaScript Grid ScreenShot.jpg
ScreenShot of JavaScript Grid
JavaScript Grid ScreenShot.jpg (7.1 KiB) Viewed 441 times
Last edited by eagleb1 on Mon Oct 21, 2019 6:04 pm, edited 1 time in total.
chivracq
Posts: 8720
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Java Grid Selection and data input

Post by chivracq » Fri Oct 18, 2019 8:13 pm

eagleb1 wrote:
Fri Oct 18, 2019 7:37 pm
How is best way to find and update data in a dynamic javascript grid. I am using lastest iMacros Pro and iMacros browser. See below for snippet of website dynamic Javascript grid and code. Thanks

Code: Select all

<td role="gridcell" id="g-01v2-8843" class="TDC g-01y2_0 FieldEnabled Field TCRight   CellQuantity CellEditable g-01v2 CellEditing" data-maxlength="30" headers="g-01v2-CH" style="padding: 0px;">
<div class="DTC" style="padding: 0px;">
<span id="c_g-01v2-8843" class="DCC">
<input type="text" spellcheck="false" style="font-size: inherit; text-align: right; text-transform: none; width: 98px; height: 31px;" maxlength="30" class="TDC g-01y2_0 FieldEnabled Field TCRight CellQuantity CellEditable g-01v2 CellEditing">
</span>
<div id="indicator_g-01v2-8843" class="FI FieldIndicator"></div>
</div>
</td>
JavaScript Grid ScreenShot.jpg

Euh..., "Java" is not the same as "JavaScript"...!
=> If you can edit your Thread Title with "JavaScript" (or "JS" or "Dynamic JS")...?

FCIM...! :mrgreen: (Read my Sig...)
"latest" doesn't mean anything on a Tech Forum, simply mention the exact Version, + your OS is missing...
From "iMacros Pro", do I understand "correctly" that you are using the "Full" Version of iMB...?, and not the 'Trial' Version...?

No Script posted, what have you tried...?, and what is the Pb...? :?

From your very "generic" OP, I can only give you some very "generic" Answer about "record your Actions using the 'TAG' / 'EVENT' / 'DS' Modes, + maybe using 'Relative Positioning'" + "read some Documentation about handling Tables with iMacros (in 'Data Extraction' Wiki-Section + Sub-Forum)"... :wink:

Mini-Hint:
If you have the (Full) 'Pro' Version, you then have access to TechSup directly as a "Professional"/Paying Customer, although I'm not sure if they answer during the WE..., the Forum is mostly (Advanced) Users helping Users, but you need "to do your part of the job", as Advanced Users like me only help Users who get "really stuck" after they've tried "their best", and "tried stg", starting by recording your Actions and reading some Documentation (and the Forum Rules also btw when you post on the Forum), I can't read the Documentation for you, well I know it by heart already, oops...! :oops:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
eagleb1
Posts: 9
Joined: Fri Oct 18, 2019 12:35 am

Re: Javascript Grid Selection and data input

Post by eagleb1 » Fri Oct 18, 2019 10:26 pm

Sorry for not having full information. Windows 7 Pro, iMacros Browser (x86) Version 12.5.503.8802, iMacros Professional Trial Version. Will purchase if this will work with the website in question. I have searched for Javascript grid but not much information. I can not give website address, it is secure anyway. I am pasting some of the iMacros code below, I have tried recording several times but since the SPAN ATTR=ID: tag changes each time, I am using a wildcard, this gets me to grid cell but I cannot figure out how to then enter the data. I eventually will try to implement a loop and reading from a csv file. I have also tried inspecting the html/Javascript code using a chrome browser and that is what I submitted. Still not sure what my operating system has to do with the iMacros browser.

I have managed to get iMacros to log into website, navigate through several layers of menus, put in several different pieces of data, respond to popups, navigate further, search the grid and get to the cell that I need to update but cannot get that cell to update. See part of my iMacro's code below.

....
TAG POS=1 TYPE=SPAN ATTR=ID:caption2_c-k
TAG POS=1 TYPE=SPAN ATTR=ID:caption2_g-d
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:g-0172 CONTENT=1327-5876
TAG POS=1 TYPE=BUTTON ATTR=TXT:OK
PAUSE
TAG POS=1 TYPE=A ATTR=TXT:"Step 1: Click here to enter order items"
'TAG POS=1 TYPE=SPAN ATTR=ID:caption2_g-k
'TAG POS=1 TYPE=A ATTR=ID:cl_g-k
WAIT SECONDS=1
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:g-0103 CONTENT=36567
TAG POS=1 TYPE=SPAN ATTR=ID:c_g-01v2-* *// gets me to cell but I cannot get it modify contents
''TAG TYPE=INPUT:TEXT CONTENT=5
PAUSE
'<span id="c_g-01v2-6450" class="DCC">0</span>
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:g-0103 CONTENT=33522
TAG POS=1 TYPE=SPAN ATTR=ID:c_g-01v2-* *// gets me to cell but I cannot get it modify contents
'TAG TYPE=INPUT:TEXT CONTENT=5
PAUSE
TAG POS=1 TYPE=BUTTON ATTR=TXT:OK
'
TAG POS=2 TYPE=BUTTON ATTR=ID:action_10
TAG POS=1 TYPE=BUTTON ATTR=TXT:Yes
TAG POS=1 TYPE=A ATTR=TXT:"Log Off"
TAG POS=1 TYPE=BUTTON ATTR=TXT:Yes
chivracq
Posts: 8720
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Javascript Grid Selection and data input

Post by chivracq » Sat Oct 19, 2019 12:13 am

eagleb1 wrote:
Fri Oct 18, 2019 10:26 pm
Sorry for not having full information.

Code: Select all

Windows 7 Pro, iMacros Browser (x86) Version 12.5.503.8802, iMacros Professional Trial Version.
Will purchase if this will work with the website in question.

I have searched for Javascript grid but not much information. I can not give website address, it is secure anyway. I am pasting some of the iMacros code below, I have tried recording several times but since the SPAN ATTR=ID: tag changes each time, I am using a wildcard, this gets me to grid cell but I cannot figure out how to then enter the data. I eventually will try to implement a loop and reading from a csv file. I have also tried inspecting the html/Javascript code using a chrome browser and that is what I submitted.

Still not sure what my operating system has to do with the iMacros browser.

I have managed to get iMacros to log into website, navigate through several layers of menus, put in several different pieces of data, respond to popups, navigate further, search the grid and get to the cell that I need to update but cannot get that cell to update. See part of my iMacro's code below.

Code: Select all

'....
TAG POS=1 TYPE=SPAN ATTR=ID:caption2_c-k
TAG POS=1 TYPE=SPAN ATTR=ID:caption2_g-d
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:g-0172 CONTENT=1327-5876
TAG POS=1 TYPE=BUTTON ATTR=TXT:OK
PAUSE
TAG POS=1 TYPE=A ATTR=TXT:"Step 1: Click here to enter order items"
'TAG POS=1 TYPE=SPAN ATTR=ID:caption2_g-k
'TAG POS=1 TYPE=A ATTR=ID:cl_g-k
WAIT SECONDS=1
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:g-0103 CONTENT=36567
TAG POS=1 TYPE=SPAN ATTR=ID:c_g-01v2-*        *// gets me to cell but I cannot get it modify contents
''TAG TYPE=INPUT:TEXT CONTENT=5
PAUSE
'<span id="c_g-01v2-6450" class="DCC">0</span>
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:g-0103 CONTENT=33522
TAG POS=1 TYPE=SPAN ATTR=ID:c_g-01v2-*         *// gets me to cell but I cannot get it modify contents
'TAG TYPE=INPUT:TEXT CONTENT=5
PAUSE
TAG POS=1 TYPE=BUTTON ATTR=TXT:OK
'
TAG POS=2 TYPE=BUTTON ATTR=ID:action_10
TAG POS=1 TYPE=BUTTON ATTR=TXT:Yes
TAG POS=1 TYPE=A ATTR=TXT:"Log Off"
TAG POS=1 TYPE=BUTTON ATTR=TXT:Yes

OK, Thanks for editing your last Post Title with "Javascript", but can you do that also with the Thread Title...?
The Thread Title is the Title of your 1st Post in the Thread, and is the Title visible from the Sub-Forum View and also for Users searching the Forum...
When you post a Reply to a Thread, the 'Thread Title' gets automatically used as the Post Title by Default, unless you post using the 'Quote' Button which then takes by Default the Post Title of the quoted Post...

(You need to pay attention to "Details" if you want to do "interesting" Things with iMacros, just like you should notice the ]CODE[ Forum Tags to format your Posts when you post a Script... :idea: )

Thanks also for your FCI... :D
About "Still not sure what my operating system has to do with the iMacros browser.", hum, you still haven't read the Forum Rules, haven't you...!? :shock:
* Always provide your FCI (Full Config Info), c.f. items 1-3 above, in your original post even if you think it may not be relevant.
Some of our mods may not even respond unless this information is included.
Yeah well, "mods", I'm the only Mod on the Forum; the "F" in "FCI" stands for "FCI"; FCI not mentioned, I usually don't read the Qt/OP, and certainly don't answer; if you want some Help from the Forum, and I am by far the most active Helper, you mention your FCI, that's simple...! :wink:
And don't worry,, once you'll be the "proud" Owner of a ''Pro' iMB License, you'll have direct Access to TechSup, and they are much "nicer" than me, ah-ah...! 8)

"I have searched for Javascript grid but not much information."
=> Beeeh..., yep, a bit normal actually, I'm probably the only (Advanced) User to have dealt with and answered "such" Threads for the last 6 years and I don't use those "Javascript + grid" Terms. (And "JavaScript" is a bit useless anyway to use as a Search Keyword on the Forum, ah-ah...!) I usually use "dynamically (or on-the-fly) + generated/populated + ajaxy + Elements" as Terminology... And I personally never use the Term "Grid" (but rather "Table")...

>>>

Then OK, good!, you've posted some Script... :D
So that means the 'TAG' Mode "works", which is good, and which I expected a bit indeed as the HTML Structure of the Table or at least that Cell (as you only posted the Source of one single Cell) "still" looks "a bit Standard" with apparently the following HTML Structure:

Code: Select all

[TABLE [TR [TD [DIV [SPAN [INPUT]] [DIV]]]]
"but since the SPAN ATTR=ID: tag changes each time, I am using a wildcard, this gets me to grid cell but I cannot figure out how to then enter the data."
=> Yep indeed, but that's a "different" Problem...

From the Source for that one Cell you've posted, I see "TDC" + "CellQuantity" that might be usable for the 'CLASS' at the 'TD' + 'INPUT' Levels, + some "DTC" and "DCC" for their 'CLASS' at the 'DIV' or 'SPAN' Level to identify and tag that Cell easily with 'POS=1', with stg like:

Code: Select all

TAG POS=1 TYPE=INPUT:TEXT ATTR=CLASS:*TDC*CellQuantity* CONTENT=5
I don't know what those "TDC"/"DTC"/"DCC" mean and if they are a bit unique from seeing only the Structure of just one Cell while I would need the Structure of the whole Table (oh sorry...! => Grid, ah-ah...! :wink: ), you can try playing a bit with "POS=2" / "=3" to see which Cell your "5" lands into, ah-ah...!

And otherwise, you'll have to use 'Relative Positioning' that I already mentioned, with the "Quantity" Header-Cell as 'Anchor', and "POS=R4" if your Table has 4 Cols per Row (which is all I can see from your mini-Printscreen). But that will only work if all Cells in Row_2 are editable and all contain an 'INPUT' Field also.

If that Nb (of editable Cells) might be variable, you'll need to use 'R-POS' at the 'TD' Level, and then use 'Double Relative Positioning' to be able to "reach" the 'INPUT' Field within that 'TD' Element...

I've explained many times the "Technique" if you search a bit the Forum on the (Search) Keywords I mentioned between Single Quotes... :idea:

But OK, I guess I've lost you a bit, and you are "a bit lucky", I'm a bit bored, ah-ah...!, so here you are, I would expect this one to probably work directly, I think, even if I can't test anything of course...:

Code: Select all

SET Nb_of_Cols 4

TAG POS=1 TYPE=TD ATTR=TXT:*Quantity*
TAG POS=R{{Nb_of_Cols}} TYPE=TD ATTR=*
TAG POS=R-1 TYPE=* ATTR=*
TAG POS=R1 TYPE=INPUT:TEXT ATTR=* CONTENT=5
You simply need to edit the "4" into what Nb of Cols you have in that Table/Grid... 8)

Not tested of course..., and enjoy if that Script works directly... :twisted:

Oh...!, and now I'm not bored anymore, my yearly Halloween Game has just started, and I need to check if my Script from last year still works, ah-ah...! :D
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
eagleb1
Posts: 9
Joined: Fri Oct 18, 2019 12:35 am

Re: Javascript Grid Selection and data input

Post by eagleb1 » Tue Oct 22, 2019 10:46 pm

chivracq thanks for your help. I tried your suggestion using relative positioning but nothing I try will enter the value which is 5. If I have iMacro stop after going to and highlighting cell value (0 in case until value added). I can then just click on cell and type 5 and then let iMacro proceed to next step. Any other suggestions would be greatly appreciated. Sorry, I do not get much time at work to work on this but really need to come up with a solution. See code below that I have tried with comments. Thanks.

TAG POS=1 TYPE=TD ATTR=ID:g-01n2-*
PAUSE
TAG POS=R8 TYPE=TD ATTR=* CONTENT=5 *// gets me to cell with qty highlighted but does not enter the 5
PAUSE
DS CMD=CLICK *// no effect
DS CMD=KEY CONTENT={BACKSPACE} *// no effect
DS CMD=KEY CONTENT=5 *// no effect
DS CMD=KEY CONTENT={ENTER} *// no effect
chivracq
Posts: 8720
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Javascript Grid Selection and data input

Post by chivracq » Wed Oct 23, 2019 1:13 am

eagleb1 wrote:
Tue Oct 22, 2019 10:46 pm
chivracq thanks for your help. I tried your suggestion using relative positioning but nothing I try will enter the value which is 5. If I have iMacro stop after going to and highlighting cell value (0 in case until value added). I can then just click on cell and type 5 and then let iMacro proceed to next step. Any other suggestions would be greatly appreciated. Sorry, I do not get much time at work to work on this but really need to come up with a solution. See code below that I have tried with comments. Thanks.

Code: Select all

TAG POS=1 TYPE=TD ATTR=ID:g-01n2-*
PAUSE
TAG POS=R8 TYPE=TD ATTR=* CONTENT=5	*// gets me to cell with qty highlighted but does not enter the 5 
PAUSE

Code: Select all

DS CMD=CLICK				*// no effect
DS CMD=KEY CONTENT={BACKSPACE}		*// no effect
DS CMD=KEY CONTENT=5			*// no effect
DS CMD=KEY CONTENT={ENTER}		*// no effect

Oh..., good, you've edited the Thread Title... :D

Hum, you still haven't found the ']CODE[' Forum Tags to format your Scripts... :idea:

>>>

Then OK, about the 2 Scripts that you've posted, beeeh, yep, normal for the 1st one, you try to use 'R-POS' on the 'TD' Element. That is good to tag it if you wanted to extract it, but I don't think you can use the 'CONTENT' Param on a 'TYPE=TD' Element, only on the 'TYPE=INPUT' Element inside that Cell.

I don't know what this Cell with "ID:g-01n2-*" is, but if it is the Header-Cell with the "Quantity" Label that I was trying to use in my 2nd Script in my previous Post, then I would expect this one to work:

Code: Select all

SET Nb_of_Cols 8

'Using 'Relative Positioning' to tag the Cell expecting the Input:
'TAG POS=1 TYPE=TD ATTR=TXT:*Quantity*
TAG POS=1 TYPE=TD ATTR=ID:g-01n2-*
TAG POS=R{{Nb_of_Cols}} TYPE=TD ATTR=*
'>
'Using 'Double Relative Positioning' to reach the 'INPUT' Element inside that Cell:
TAG POS=R-1 TYPE=* ATTR=*
TAG POS=R1 TYPE=INPUT:TEXT ATTR=* CONTENT=5
>>>

The 'DS' Statements you are also trying to use in your 2nd Script should trigger some Syntax Error I would expect, as you've omitted/removed the 'X/Y' Coordinates. :oops:

But, pffff..., the 'DS' Mode would really be my "last Choice", as it relies on Coordinates, and depends on the Screen Size/Resolution + Window Size + Width of the iMacros Side Panel, and I would find it pretty "unreliable" in your Case. :(
You could better use the 'EVENT' Mode then, if the 'TAG' Mode really doesn't work, as it will at least follow the HTML Structure of your Table... :idea:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
eagleb1
Posts: 9
Joined: Fri Oct 18, 2019 12:35 am

Re: Javascript Grid Selection and data input

Post by eagleb1 » Thu Oct 24, 2019 5:03 pm

Thank you for help, this is the code that I ended up using based on your suggestions.

TAG POS=1 TYPE=SPAN ATTR=CLASS:DCC&&TXT:{{CodeNo}}
WAIT SECONDS=1
TAG POS=R8 TYPE=TD ATTR=*
TAG POS=R-1 TYPE=* ATTR=*
TAG POS=R1 TYPE=INPUT:TEXT ATTR=* CONTENT={{ItemQty}}
chivracq
Posts: 8720
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Javascript Grid Selection and data input

Post by chivracq » Thu Oct 24, 2019 6:02 pm

eagleb1 wrote:
Thu Oct 24, 2019 5:03 pm
Thank you for help, this is the code that I ended up using based on your suggestions.

Code: Select all

TAG POS=1 TYPE=SPAN ATTR=CLASS:DCC&&TXT:{{CodeNo}}
WAIT SECONDS=1
TAG POS=R8 TYPE=TD ATTR=*
TAG POS=R-1 TYPE=* ATTR=*
TAG POS=R1 TYPE=INPUT:TEXT ATTR=* CONTENT={{ItemQty}}

Yep, perfect, exactly what I meant... :D

And I hope you understood the Principle of 'R-POS' + 'Double R-POS'... :wink:

And I'm "glad" it works with the 'TAG' Mode, but you should maybe still have "a look" at the 'EVENT' Mode, by tagging and "reaching" several Cells in your Table and to "study" a bit the Statements that will get recorded to understand its Syntax... Your Table is a perfect Example, that will produce some "pretty straightforward" Statements/Syntax to understand a bit how the 'EVENT' Mode works..., and that might "save you" the Trouble one day from opening 1-2-3 Threads on the Forum or with TechSup... :idea:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
eagleb1
Posts: 9
Joined: Fri Oct 18, 2019 12:35 am

Re: Javascript Grid Selection and data input

Post by eagleb1 » Thu Oct 24, 2019 10:14 pm

Yes, Thank You. Now that I have that working and iMacros will login, navigate through several menus, add order header info, then add order detail lines from a csv file with only one order and static number of line items, I have run into another issue and not sure if I need to start New Post? I am sending orders to a website from a database and because I noticed that iMacros could read from a csv file and loop, I assumed (I know that is a problem in it self) that there was commands in the iMacros scripting language to perform loops and even have loops inside of loops with conditional statements. This does not appear to be the case and I am hoping that I do not have to purchase the enterprise edition just to be able to script a loop within a loop. The outer loop would read the order header info and fill in web page according and then second loop would enter the order line items (could be from 1 to 6 items per order) then submit order, exit to outer loop and start over with new order header and on and on. Do you have any advice on best way to tackle this looping? Thanks.
chivracq
Posts: 8720
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Javascript Grid Selection and data input

Post by chivracq » Thu Oct 24, 2019 11:09 pm

eagleb1 wrote:
Thu Oct 24, 2019 10:14 pm
Yes, Thank You. Now that I have that working and iMacros will login, navigate through several menus, add order header info, then add order detail lines from a csv file with only one order and static number of line items, I have run into another issue and not sure if I need to start New Post? I am sending orders to a website from a database and because I noticed that iMacros could read from a csv file and loop, I assumed (I know that is a problem in it self) that there was commands in the iMacros scripting language to perform loops and even have loops inside of loops with conditional statements. This does not appear to be the case and I am hoping that I do not have to purchase the enterprise edition just to be able to script a loop within a loop. The outer loop would read the order header info and fill in web page according and then second loop would enter the order line items (could be from 1 to 6 items per order) then submit order, exit to outer loop and start over with new order header and on and on. Do you have any advice on best way to tackle this looping? Thanks.

Yep-yep, everything can be done in "pure" '.iim', I have a "Solution" for all Functionality that you want in pure '.iim' (usually using the 'EVAL()' Command), without the Need for 'SI' (the 'Scripting Edition')... I only use '.iim' Scripts myself, even if the Versions I use (v8.8.2 for FF + v8.9.7 for FF) do support '.js' Scripts, but I "prefer" (for myself) to do all my Coding/Web-Automation in pure '.iim' rather than using JS for a '.js' Script or any "external" Scripting/Coding Language... It might sometimes be more "straightforward" using 'SI' with some Scripting Language, but I('ve) always find/found a Way to do everything that I need in pure '.iim', so it's "doable", ah-ah...! :twisted:

I've posted (nearly :twisted: ) all my "Techniques" on the Forum already, if you search a bit... :idea:
Like I had already mentioned, I (usually) only help Users who "really get stuck", but you'll need "to do your part of the job", ah-ah...! :wink:

(But I guess once you'll have your 'Pro' License for iMB, TechSup are a bit more "Customer Friendly" than me, and will probably give you the/a Solution directly on any Qt you might have... But I don't or very rarely write Scripts for other Users, I prefer to let you/them "understand" what you/them "are doing", and find "the Solution" by your/themselves..., which is more "rewarding" for you/them, I would think... And the quicker you/they "learn", the quicker you/they don't need me and the Forum anymore, ah-ah...! :P :( )

And to search the Forum, you need to use the "correct" Search Keywords, just like I don't use "Grid" as a Term, I use "Nested Loop(s)" for your "loops inside of loops", and I use "Conditional Behaviour/Logic" (with the UK-Eng Spelling for "Behaviour") for your "conditional statements" for example... :oops:

Some "interesting" Thread to get you "started" about 'Conditional Behaviour' in pure '.iim'...:
- Workarounds for Conditional Logic in Macro Code

And then, yep, open some separate Thread(s) if you encounter some "Difficulties" implementing any specific Functionality... :)
(All Threads as "Standalone" Threads, with FCI mentioned (preferably at the complete Top of your OP), some (concrete) Script and what you've tried, Ref/Links to other Threads/Resources you might have used, etc... :!: )
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
eagleb1
Posts: 9
Joined: Fri Oct 18, 2019 12:35 am

Re: Javascript Grid Selection and data input

Post by eagleb1 » Fri Oct 25, 2019 8:49 pm

I have looked at many of the nested loop threads but still having trouble understanding how to only execute portions of macros during certain loops. I am also having trouble with the EVAL() statement, I am guessing that I need to understand Java script for this? I am trying to use the EVAL() statement (not working) to output a 1 or 0 for POS while using !ERRORIGNORE but this will not stop the URL step from executing. Help with EVAL() syntax would be great. I am also including full Macro (had to asterisk out sensitive data) for any pointers that anyone might have and example csv data. Any pointers would be much appreciated.

]CODE[
VERSION BUILD=12.5.503.8802
TAB T=1
TAB CLOSEALLOTHERS
'SET !PLAYBACKDELAY 0.00
SET !ERRORIGNORE YES
SET UsePos EVAL("IF {{COL2}} = {{PrevAcctId}}; 0; else 1;")
URL GOTO=https://***.***.ms.***/_/
TAG POS={{UsePOS}} TYPE=INPUT:TEXT ATTR=NAME:d-n CONTENT=********
'TAG POS=1 TYPE=BUTTON ATTR=NAME:d-p
SET !ENCRYPTION NO
TAG POS={{UsePOS}} TYPE=INPUT:PASSWORD ATTR=NAME:d-o CONTENT=********
TAG POS={{UsePOS}} TYPE=BUTTON ATTR=NAME:d-p
TAG POS={{UsePOS}} TYPE=SPAN ATTR=ID:caption_c-7
TAG POS={{UsePOS}} TYPE=A ATTR=TXT:"****** *******"
TAG POS={{UsePOS}} TYPE=A ATTR=TXT:"Add/View Special Orders"
TAG POS={{UsePOS}} TYPE=SPAN ATTR=ID:caption2_c-k
TAG POS={{UsePOS}} TYPE=SPAN ATTR=ID:caption2_g-d
SET !DATASOURCE Z:/TestSO.CSV
' ----- Main Loop - Reads Account ID from csv as !COL2 --------------
PROMPT "Loop is {{!LOOP}}"
SET !DATASOURCE_LINE {{!LOOP}}
SET PrevAcctID {{COL2}}
TAG POS={{UsePOS}} TYPE=INPUT:TEXT ATTR=NAME:g-0172 CONTENT={{COL2}}
TAG POS={{UsePOS}} TYPE=BUTTON ATTR=TXT:OK
WAIT SECONDS=4
TAG POS={{UsePOS}} TYPE=A ATTR=TXT:"Step 1: Click here to enter order items"
WAIT SECONDS=1
' ------ Secound Loop - Reads Order Items from csv as !COL3 and Qty as !COL4
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:g-0103 CONTENT={{COL3}}
TAG POS=1 TYPE=SPAN ATTR=CLASS:DCC&&TXT:{{COL3}}
WAIT SECONDS=1
TAG POS=R8 TYPE=TD ATTR=*
TAG POS=R-1 TYPE=* ATTR=*
TAG POS=R1 TYPE=INPUT:TEXT ATTR=* CONTENT={{COL4}}
WAIT SECONDS=2
' ------ End of Second Loop - should loop until !COL2 changes
WAIT SECONDS=2
TAG POS={{UsePOS}} TYPE=BUTTON ATTR=TXT:OK
'
WAIT SECONDS=4
ONPRINT P=* BUTTON=PRINT
PRINT
' ------ End of Main Loop - should loop until end of csv
]CODE[

]DATA[
csv data example, 4 cols, col1 is order id, col2 is account id, col3 is item, col4 is qty - # of items per order is dynamic from 1 to 6
1 1327-0001 36567 5
1 1327-0001 33522 4
2 1327-0002 33565 2
3 1327-0003 22554 3
3 1327-0003 225455 2
3 1327-0003 22563 2
]DATA[
Last edited by eagleb1 on Fri Oct 25, 2019 11:41 pm, edited 1 time in total.
chivracq
Posts: 8720
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Javascript Grid Selection and data input

Post by chivracq » Fri Oct 25, 2019 9:13 pm

Yeah..., but this is getting "messy" for this current Thread, your last post is not about the original Scenario/Functionality about accessing a specific Cell in a Table anymore, open a New (Standalone) Thread I told you...: :roll:
And then, yep, open some separate Thread(s) if you encounter some "Difficulties" implementing any specific Functionality... :)
(All Threads as "Standalone" Threads, with FCI mentioned (preferably at the complete Top of your OP), some (concrete) Script and what you've tried, Ref/Links to other Threads/Resources you might have used, etc... :!: )
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
Post Reply