Search code examples
javascriptimacros

Form fields with random IDs


I have created a javascript to automate the below form but some form fields generate random IDs so it wont run. My Script

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;

it generates a random ATTR=ID everytime when refresh the form. any solution?


Solution

  • If you have a fixed order of these input fields, you might not need the IDs anyhow. You could just increase the POS number for every field and use * ATTRs, i.e. your code turns into

    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;
    [..]