HighDots Forums  

submiting to cgi, without an html file

Javascript JavaScript language (comp.lang.javascript)


Discuss submiting to cgi, without an html file in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Robert Diamond
 
Posts: n/a

Default submiting to cgi, without an html file - 04-21-2004 , 03:14 AM






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)




Reply With Quote
  #2  
Old   
Csaba Gabor
 
Posts: n/a

Default Re: submiting to cgi, without an html file - 04-21-2004 , 06:19 AM






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" <-rob- (AT) anti (DOT) spam.com> wrote

Quote:
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)






Reply With Quote
  #3  
Old   
Robert Diamond
 
Posts: n/a

Default Re: submiting to cgi, without an html file - 04-21-2004 , 06:29 AM



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



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.