$(document).ready(function () { $("#htmlsubmit").mouseover(function () { var values = "{" $("input").each(function () { if ($(this).attr("type") == "text" || $(this).attr("type") == "number" || $(this).attr("type") == "email" || $(this).attr("type") == "date") { values = values + "'" + $(this).attr("name") + "': '" + $(this).val() + "', " } }); values = values + "}"; var localhost = window.location.protocol + "//" + window.location.host; var address = localhost + "/checkIn/user/success/?values=" + values; $("#htmlsubmit").attr("href", address); }); });