Com o método window.open abro um novo site com parâmetros, que tenho que passar pelo método post. Encontrei a solução, mas infelizmente não funciona. Este é o meu código:
<script type="text/javascript">
function openWindowWithPost(url,name,keys,values)
{
var newWindow = window.open(url, name);
if (!newWindow) return false;
var html = "";
html += "<html><head></head><body><form id='formid' method='post' action='" + url +"'>";
if (keys && values && (keys.length == values.length))
for (var i=0; i < keys.length; i++)
html += "<input type='hidden' name='" + keys[i] + "' value='" + values[i] + "'/>";
html += "</form><script type='text/javascript'>document.getElementById(\"formid\").submit()</sc"+"ript></body></html>";
newWindow.document.write(html);
return newWindow;
}
</script>
Em seguida, crio matrizes:
<script type="text/javascript">
var values= new Array("value1", "value2", "value3")
var keys= new Array("a","b","c")
</script>
E chamar a função por:
<input id="Button1" type="button" value="Pass values" onclick="openWindowWithPost('test.asp','',keys,values)" />
Mas, quando clico neste botão, o site test.asp está vazio (é claro que tento obter valores de aprovação - Request.Form("b")).
Como eu poderia resolver esse problema, por que não consigo passar valores?