如何在PHP变量中作为函数的一部分的html代码中运行Javascript [duplicate]

I am struggling to get the Javascript action going in the "onchange" event in the below example. I have tried all sorts of different syntax, but it does not work.

function display(){

    $headingData ='<select name="input" id="input" onchange="$("#frmInput").submit()" >';
        $headingData.='<option value="...." '.$selected.'>Selection1</option>';
        $headingData.='<option value="...." '.$selected.'>Selection2</option>';
    $headingData.='</select>

    return $headingData;
}
</div>