submiting to cgi, without an html file

R

Robert Diamond

Hey guys (and girls ;)),

I want to create some form data and submit
it to the cgi script without having any (DOM) document loaded up. Is there a
way in jscript to say... (probably something like...)

var myFormObject = new document(actionHref, encryptType, etc...,
nameOfFormField, valueOfFormField, etc...);

myFormObject.submit();

I could always write a litle html file with a body of hidden fields and set
thier values (ie: window.chathtm.form.field = whatever), but i don't really
want the overhead of downloading the extra page... ok, that's
a lie... i'm anal and just want to not load the htm file ;)

So all i want is to submit a form (and it's data) to a cgi script, using
jscript, without actually having an html file (it's from a frame based so
the
jscript is running from the top window, and the cgi script is in a frameset
window)
 
C

Csaba Gabor

I don't know anything about JScript so I'm going to assume javascript.
You can create an internal form element, and then populate it
in turn with <input type=hidden fields ...> for each of the name/value
pairs that you want. I'd make a variable argument function:
constructInternalForm (method, action, target, name1, val1, name2, val2,
....)
which returns the form object, then just submit it.
In case you haven't done it before, down near the bottom of the page
on http://www.devguru.com/Technologies/xmldom/quickref/obj_node.html
you can see a list of useful methods by which to construct your internal
form
(the appendChild doesn't quite match the way I use it).

Csaba Gabor
PS. Here's a starter kit,

<BODY id=myBod>
<SCRIPT type='text/javascript'>
var myBod = document.getElementById('myBod');
var myForm = document.createElement("FORM");
myForm.id = "internalForm";
myForm.target = "iframeName";
myForm = myBod.appendChild(myForm);
var myInput = document.createElement("INPUT");
myInput.name = "firstName";
myInput.type = "hidden";
myInput.value = "Hi Mom";
myForm.appendChild(myInput);
alert(document.getElementById('internalForm')[0].value);
</SCRIPT>
</BODY>
 
R

Robert Diamond

Sweet, just what i was looking for, thanks, would have been lost without
this ;) Time for coffee though, then back to the script ^.~
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top