[JS] Passing variable for select input type

Discussions and Tech Support specific to the iMacros Firefox add-on.
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
Anonymickey
Posts: 1
Joined: Thu Jun 09, 2011 10:08 pm

[JS] Passing variable for select input type

Post by Anonymickey » Thu Jun 09, 2011 10:28 pm

Well, I've been trying to play with iMacros for some time now, and I've managed to do some progress, but while I was trying to write a macro, I realized that the following code works...

Code: Select all

TAG POS=1 TYPE=SELECT FORM=NAME:cpform ATTR=ID:sel_period_3 CONTENT=$P*
while when I try to do it setting a variable with JavaScript, it doesn't work. Here's my code:

Code: Select all

TAG POS=1 TYPE=SELECT FORM=NAME:cpform ATTR=ID:sel_period_3 CONTENT={{TIME}}
I tried with the three following syntaxes on JavaScript, but none successfully.

Code: Select all

iimSet("TIME", "$P*");

Code: Select all

iimSet("TIME",  '$P*');

Code: Select all

iimSet("TIME", /$P*/);
The error I get is:

Code: Select all

RuntimeError: Wrong format of CONTENT value, line: 3 (Error code: -1001)
iMacros Build: 7220523
OS: Windows 7 (x86), Portuguese
Browser: Firefox Nightly Build 7.0a1



Am I doing something wrong? I'd appreciate any help.

Thanks,
Raphael.
siniy
Posts: 118
Joined: Sat Nov 07, 2009 7:44 pm

Re: [JS] Passing variable for select input type

Post by siniy » Fri Jun 10, 2011 5:43 am

Try without iimset.

Code: Select all

var mytime = "$P*";
var macro;
macro =  "CODE:";
macro +=  "TAG POS=1 TYPE=SELECT FORM=NAME:cpform ATTR=ID:sel_period_3 CONTENT="+ mytime + "\n"; 
alert(macro);
iimPlay(macro);
Tom, Tech Support
Posts: 3613
Joined: Mon May 31, 2010 4:59 pm

Re: [JS] Passing variable for select input type

Post by Tom, Tech Support » Wed Jun 22, 2011 3:55 pm

Hello Anonymickey,

The following syntax works well in iMacros Browser/IE:

Code: Select all

URL GOTO=http://www.iopus.com/imacros/demo/v6/f1/form.asp
SET !VAR1 %Fre*
TAG POS=1 TYPE=SELECT FORM=ID:TestForm ATTR=NAME:main CONTENT={{!VAR1}}
But with iMacros for Firefox you would have to use the following syntax instead:

Code: Select all

URL GOTO=http://www.iopus.com/imacros/demo/v6/f1/form.asp
SET !VAR1 Fre
TAG POS=1 TYPE=SELECT FORM=ID:TestForm ATTR=NAME:main CONTENT=%{{!VAR1}}*
siniy's suggestion is also a good workaround.
Regards,

Tom, iMacros Support
Post Reply