Con il metodo window.open apro un nuovo sito con parametri, che devo passare per metodo post.Ho trovato soluzione, ma purtroppo non funziona. Questo è il mio codice:
<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>
Successivamente, creo array:
<script type="text/javascript">
var values= new Array("value1", "value2", "value3")
var keys= new Array("a","b","c")
</script>
E chiama la funzione:
<input id="Button1" type="button" value="Pass values" onclick="openWindowWithPost('test.asp','',keys,values)" />
Ma, quando clicco su questo pulsante, il sito test.asp è vuoto (ovviamente provo a ottenere valori di passaggio - Request.Form("b")).
Come posso risolvere questo problema, perché non riesco a ottenere i valori passati?