0

I’ve already tried to get the element by id, however, the html does not include it. As shown below, this is the script for the drop down that I am trying to change automatically. It will change the name with

appIE.Document.getElementById("supervisor").Value = "Sup_name"

However, it doesn’t fire the event that generates a list of people.

The top of the form also includes <form id='filterform' action="javascript:void(0);">

The JavaScript containing the function I need to call is below.

<script type="text/javascript">

    $(function() {
        $('#supervisor').change(function() {
            document.getElementById('results').innerHTML = '<img src="/img/busy.gif" />';
            var str = $('#filterform').serializeArray();
            $.ajax({
                url: 'ajax.php?p=agentrosters&mode=1&field=supervisor',
                type: 'POST',
                data: str,
                success: function(j) {
                    //alert(j);
                    document.getElementById('results').innerHTML = j;
                    document.getElementById('lastsearch').value = 'supervisor';
                    resetscript('supervisor');
                },
                failure: function() {
                    document.getElementById('results').innerHTML = 'There has been an error, please try again';
                    resetscript('null');
                }
            })
        })
    })

</script>

Any Ideas on how I can get this to work?

4
  • Try appIE.Document.getElementById("supervisor").change() or appIE.Document.getElementById("supervisor").Firevent("onchange") Commented Jan 25, 2016 at 1:24
  • I tried both but neither one worked. The first one gave me an error "expecting =" Commented Jan 25, 2016 at 1:38
  • Typo - .Firevent("onchange") >> .FireEvent("onchange") Commented Jan 25, 2016 at 1:43
  • Even with the typo corrected it still did not properly fire the JavaScript event. Commented Jan 25, 2016 at 1:45

1 Answer 1

1

If the element is part of a form you may to submit the form, alternatively you can use the onchange event on the element itself. So you may want to change

appIE.Document.getElementById("supervisor").Value = "Sup_name"

to

With appIE.document.getElementById("supervisor") .Value = "Sup_name" .onchange End with

And if it is part of a form change the ".onchange" to ".parentElement.Submit"

This worked for me.

Sign up to request clarification or add additional context in comments.

1 Comment

Are you sure this is correct Javascript syntax? This link suggests otherwise: developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.