Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jul 2002
    Location
    New York
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Using forms in JavaScript

    I tried doing this completely from JavaScript w/o html. We'll say for my purposes.. this is the way I need it done. Any suggestions how to declare the form w/o html <form> tags?
    Code:
    <html>
    <script language="javascript">
    function test() {
    document.form[0].action="from.asp";
    document.form[0].method="post";
    document.form[0].name="Stephen";
    document.form[0].age=17;
    doucment.form[0].submit();
    }
    </script>
    <a href="javascript:test();">Hello</a>
    </html>
    this returns the error:
    Error: 'document.form.0' is null or not an object
    -Stephen

  • #2
    Regular Coder
    Join Date
    Aug 2002
    Location
    IN, USA
    Posts
    121
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If my sources are correct, the collection should be

    document.forms[0]

    not

    document.form[0]
    Just call me Crash...
    "Crash- and BURN!"
    -Cereal Killer

  • #3
    New Coder
    Join Date
    Dec 2002
    Location
    Florida
    Posts
    68
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I concur, forms, not form.

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You aren't going to do it without <form> tags on your page, if you didn't want to use the POST method you could simulate it but POST is going to require a form. That shouldn't be a problem though because you can use hidden fields on the form instead of visible fields so your whole form is hidden from the user's view.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •