This is JavaScript basics. Here is how you will do it:
Set textbox value -
document.getElementById("txtName").value = "somevalue";
Get the selected index of dropDown -
var index = document.getElementById("ddlCountry").selectedIndex
BTW doing this in jQuery will reduce writing code more. Here's how you do the same thing in jQuery -
$("#txtName").val("somevalue");
var index = $("#ddlCountry").prop("selectedIndex");