带有随机ID的表单字段

时间:2017-09-06 03:59:37

标签: javascript imacros

我创建了一个javascript来自动化下面的表单 但是一些表单字段会生成随机ID,因此它不会运行。 我的剧本

code+='URL GOTO=https://msecurea.mlb.com/hou/bam-forms/hou-postseason-ticket-opportunity-2017'+newline;
    code+='TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:bam.form ATTR=ID:idj77vrd51 CONTENT={{!COL1}}'+newline;
    code+='TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:bam.form ATTR=ID:idj77vrd52 CONTENT={{!COL2}}'+newline;
    code+='TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:bam.form ATTR=ID:idj77vrd53 CONTENT={{!COL3}}'+newline;
    code+='TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:bam.form ATTR=ID:idj77vrd55 CONTENT={{!COL4}}'+newline;
    code+='TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:bam.form ATTR=ID:idj77vrd56 CONTENT={{!COL5}}'+newline;
    code+='TAG POS=1 TYPE=SELECT FORM=NAME:bam.form ATTR=ID:idj77vrd58_0 CONTENT=%{{!COL6}}'+newline;
    code+='TAG POS=1 TYPE=SELECT FORM=NAME:bam.form ATTR=ID:idj77vrd58_1 CONTENT=%{{!COL7}}'+newline;
    code+='TAG POS=1 TYPE=SELECT FORM=NAME:bam.form ATTR=ID:idj77vrd58_2 CONTENT=%{{!COL8}}'+newline;

每次刷新表单时都会生成一个随机的ATTR = ID。 任何解决方案?

1 个答案:

答案 0 :(得分:0)

如果您有这些输入字段的固定顺序,则无论如何您可能不需要ID。您可以只增加每个字段的POS号并使用* ATTR,即您的代码变为

code+='URL GOTO=https://msecurea.mlb.com/hou/bam-forms/hou-postseason-ticket-opportunity-2017'+newline;
code+='TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:bam.form ATTR=* CONTENT={{!COL1}}'+newline;
code+='TAG POS=2 TYPE=INPUT:TEXT FORM=NAME:bam.form ATTR=* CONTENT={{!COL2}}'+newline;
[..]
code+='TAG POS=1 TYPE=SELECT FORM=NAME:bam.form ATTR=* CONTENT=%{{!COL6}}'+newline;
code+='TAG POS=2 TYPE=SELECT FORM=NAME:bam.form ATTR=* CONTENT=%{{!COL7}}'+newline;
[..]