I have a JavaScript function to send two POST parameters, one variable and one hardcoded. However, when this function sends POST parameters, actually it sends only the first parameter and not the second. I can't figure out why is this happening The function code is :
function post_to_url(path, params, method) {
method = method || "post"; // Set method to post by default if not specified.
var form = document.createElement("form");
form.setAttribute("method", method);
form.setAttribute("action", path);
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", "sortvalue");
hiddenField.setAttribute("value", params);
var hiddenFieldMode = document.createElement("input2");
hiddenFieldMode.setAttribute("type", "hidden");
hiddenFieldMode.setAttribute("name", "mode");
hiddenFieldMode.setAttribute("value", "showmain");
form.appendChild(hiddenField);
form.appendChild(hiddenFieldMode);
document.body.appendChild(form);
form.submit();
}
I saw the POST data and it is always sortvalue=givenvalue and not sortvalue=givenvalue&mode=showmain as expected..