1: function postData()
2: { 3: //get the map 3: mapObj = GetMap();
4:
5: //define the new form
6: var newForm = document.createElement("form"); 7: //set the method to POST - the opposite of query strings..
8: newForm.method="POST";
9: //add the new form to the current document
10: document.body.appendChild(newForm);
11:
12: //lets get some data and add it to the form
13: AddFormElement(newForm, "MapName", oMap.GetMapName());
14: AddFormElement(newForm, "SID", oMap.GetSessionId());
15: //be sure you escape the selection XML - or you will get an error on post about a
16: //"potentially dangerous form value". Remember on the server side to Server.UrlDecode() it
17: AddFormElement(newForm, "sel", escape(oMap.GetSelectionXML()));
18:
19: //lets create our new window
20: var szTarget = "targetWin"
21: newForm.target = szTarget;
22: //set the name/path of the ASPX file you want to process your form with
23: newForm.action = "/url_to_open/file.aspx"
24:
25: //open a new window to submit the form to. Its a good idea to have a blank.htm so you don't get a file not found error
26: var oWin = window.open("blank.htm",szTarget,'menubar=yes, resizable=yes,scrollbars=yes, status=no,toolbar=no,width=300, height=300'); 27:
28: //give the window focus. Users like this
29: oWin.focus();
30:
31: //submit the form - it will now open in the new window
32: newForm.submit();
33: //remove the form from the document, we're done with it
34: document.body.removeChild(newForm);
35: }
36:
37: function AddFormElement(form, elementName, elementVal)
38: { 39: var newElement = document.createElement("<input name='" + elementName + "' type='hidden'/>"); 40: newElement.value = elementVal;
41: form.appendChild(newElement);
42: return form;
43: }