Can't Focus Field on Safari Form that Is Being Read Correctly by Keyboard Maestro

I'm using Keyboard Maestro to fill in form values in Safari.

I'm using the set field Safari action

Keyboard Maestro is able to see the form field in the safari dropdown of the action. When I run the macro I get an error that it can't find the field. When I look at the page source I can see that the field name is correct. Any idea why it can't find the field?

FYI there are 8 other form fields on the same page that are working perfectly using the same action.

Do you select any radio buttons or similar that might make the field editable? I had a similar issue on eBay.

No it’s a select field.

Here's the code:

<select id="company_years_owned" name="company[years_owned]" tabindex="10"><option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4" selected="selected">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>
<option value="37">37</option>
<option value="38">38</option>
<option value="39">39</option>
<option value="40">40</option></select>`Preformatted text`

I was able to change the value of the field using “Execute Javascript in Safari” with the following code

document.getElementById("company_years_owned").value = "6";

How can I pass a Keyboard Maestro variable into my script to set the value?

I found how to set a KM variable into the java script action

var myData = document.kmvar.YearsInBusinessYEARS;

So the full javascript that’s working is

   var myData = document.kmvar.YearsInBusinessYEARS;
   document.getElementById("company_years_owned").value = myData;

Looks like you’ve got it all under control :slight_smile:

A post was split to a new topic: Problems Using Set Safari Field