I need to be able to create a query based off the users input of "Test" in an INPUT of Site A (SiteA.com) that will open Site B in the same window once submitted, passing along the query (SiteB.com/search.aspx?k=test).
Code on SiteA.com
var siteSearch = "SiteB.com/search.aspx";
$("#sitesubmitBtn").click(submitClick);
function submitClick() {
    var q = $(location).attr('protocol') + "//" + $(location).attr('hostname') + siteSearch;
    var k = $("#sitesearchInput").val();
    window.location.href = q + "?k=" + k;
    return false;
}
<input name="search" placeholder="Search" id="sitesearchInput" type="text">
<button id="sitesubmitBtn" type="submit"></button>