submiting to cgi, without an html file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Robert Diamond

    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(action Href, encryptType, etc...,
    nameOfFormField , valueOfFormFiel d, etc...);

    myFormObject.su bmit();

    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)



  • Csaba Gabor

    #2
    Re: submiting to cgi, without an html file

    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:
    constructIntern alForm (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.getEle mentById('myBod ');
    var myForm = document.create Element("FORM") ;
    myForm.id = "internalFo rm";
    myForm.target = "iframeName ";
    myForm = myBod.appendChi ld(myForm);
    var myInput = document.create Element("INPUT" );
    myInput.name = "firstName" ;
    myInput.type = "hidden";
    myInput.value = "Hi Mom";
    myForm.appendCh ild(myInput);
    alert(document. getElementById( 'internalForm')[0].value);
    </SCRIPT>
    </BODY>



    "Robert Diamond" <-rob-@anti.spam.com> wrote in message
    news:e3qhc.2409 $SJh1.1033@news 04.bloor.is.net .cable.rogers.c om...[color=blue]
    > 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[/color]
    a[color=blue]
    > way in jscript to say... (probably something like...)
    >
    > var myFormObject = new document(action Href, encryptType, etc...,
    > nameOfFormField , valueOfFormFiel d, etc...);
    >
    > myFormObject.su bmit();
    >
    > I could always write a litle html file with a body of hidden fields and[/color]
    set[color=blue]
    > thier values (ie: window.chathtm. form.field = whatever), but i don't[/color]
    really[color=blue]
    > 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[/color]
    frameset[color=blue]
    > window)
    >
    >
    >[/color]


    Comment

    • Robert Diamond

      #3
      Re: submiting to cgi, without an html file

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


      Comment

      Working...