0

Hi guys below are two fragments from my code:

            case 'i_new_call':
        {
            if (oSipSessionCall) {
                // do not accept the incoming call if we're already 'in call'
                e.newSession.hangup(); // comment this line for multi-line support
            }
            else {
                oSipSessionCall = e.newSession;
                oSipSessionCall.setConfiguration(oConfigCall);
                uiBtnReceive('Answer');
                btnCall.disabled = true;
                btnHangUp.disabled = false;

                startRingTone();

                var sRemoteNumber = (oSipSessionCall.getRemoteFriendlyName() || 'unknown');
                txtCallStatus.innerHTML = "<i>Incoming call from [<b>" + sRemoteNumber + "</b>]</i>";
                showNotifICall(sRemoteNumber);
            }
            break;
        }

My function is:

function uiBtnReceive() {

            var btnAccept = document.getElementsByName("Accept");
            btnAccept.onclick = function () { sipCall(bDisableVideo ? 'call-audio' : 'call-audiovideo'); };
        }
    }

Button:

<input type="button" name="Accept" style="margin: 0; vertical-align:middle; height: 100%;" class="btn btn-primary" value="Accept"/>

The problem is that when I create button with id of btnAccept it works. But when I am trying to use element name it doesn't triggered. Any idea how can I solve this.

2
  • getElementsByName("Accept") always returns an array of all the elements with the name="Accept" attribute, you could specify to only take the first like this: getElementsByName("Accept")[0] Commented Dec 15, 2016 at 11:21
  • yes I saw thank you so much for comment Commented Dec 15, 2016 at 12:01

1 Answer 1

0

getElementsByName returns array of elements you will need to use index to get the object and attach event.

function uiBtnReceive() {
   var btnAccept = document.getElementsByName('Accept')[0];
   btnAccept.onclick = function () { sipCall(bDisableVideo ? 'call-audio' : 'call-audiovideo'); };

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

1 Comment

oooo man thank you so much ))))))))) I just realised )))))))))))))))))))))))) Thanks again

Your Answer

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