Stessa minestra, un po' riscaldata:
Metti questo codice in un file *.js
codice:
<!--
/* Questo codice va in un file esterno */
//-------------------------------------------------------------------------------------
// crea un form e fa submit passando dati POST
// utilizzo:
// w = window.open("", "popup", "left=100px, top=100px, width=500px, height=400px,");
// w.focus();
// submitData("a.aspx", "popup", {nome:'Pietro', numero:'999', data:'15/3/1955'});
//-------------------------------------------------------------------------------------
function submitData(url, target, data)
{
var form = document.createElement("form");
form.action = url;
form.target = (target)? target: "_self";
form.method = "post";
form.style.display = "none";
for(var key in data) addParam(form, key, data[key]);
document.body.appendChild(form);
form.submit();
document.body.removeChild(form);
}
//----------------------------------------------
// aggiunge hidden ad un form
//----------------------------------------------
function addParam(form, key, value)
{
var input = document.createElement("input");
input.type = "hidden";
input.name = key;
input.value = value;
form.appendChild(input);
}
//-->
La tua pagina che vuole spedire variabili ad una pagina server, avrà per esempio un evento click di un pulsante
codice:
var w = null;
function Button1_onclick()
{
w = window.open("", "popup", "left=100px, top=100px, width=500px, height=400px,");
w.focus();
submitData("submit_data_action.asp", "popup", {nome:'Pietro', numero:'999', data:'17/2/2006'});
}
dove, come puoi vedere, spedisco id dati ad un popup, nella pagina submit_data_action.asp.
I dati spediti sono:
nome:'Pietro', numero:'999', data:'17/2/2006'