469,610 Members | 1,494 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,610 developers. It's quick & easy.

submiting to cgi, without an html file

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)

Jul 23 '05 #1
2 1661
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/.../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>

"Robert Diamond" <-r***@anti.spam.com> wrote in message
news:e3******************@news04.bloor.is.net.cabl e.rogers.com...
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)

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

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Bartosz Wegrzyn | last post: by
6 posts views Thread by Abby Lee | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.