submit form data approaches

Discussion in 'HTML' started by Matt, Jun 26, 2004.

  1. Matt

    Matt Guest

    I tried to figure out how many approaches to submit form data. Here's my
    attempts.
    Please advise. Thanks!!

    1) html submit button, most commonly used.

    <form name="formName" action="url" method="post">
    <input type="submit">

    2) html regular button, and a JavaScript to invoke the form.submit() method

    <form action="url"
    function submitForm()
    { //etc...
    formName.submit();
    }
    <input type="button" onClick="submitForm()">

    3) onsubmit event handling
    <form name="formName" action="url" method="post" onsubmit="return
    submitForm()">
    function submitForm()
    { //etc...
    //formName.submit(); //NOT NECESSARY!!
    }
    <input type="submit">
    Matt, Jun 26, 2004
    #1
    1. Advertising

  2. Matt

    Jeff Thies Guest

    "Matt" <> wrote in message
    news:...
    > I tried to figure out how many approaches to submit form data.


    Or, none of the below.

    Typically this is done with three submit buttons, each with the same name
    but a different value.

    Have your server script parse which button was used by looking at the
    value, and then send the data on it's way.

    If you must use javascript, then do something like this

    <form onsubmit="changeAction()">....

    function changeAction(){
    var form=document.forms[0];

    if(form['submit_name'].value == 'action1'){
    form.action='some_server_script...

    You may have to adjust that as I'm not sure if javascript will read the
    pushed submit value without some help.

    Jeff





    >Here's my
    > attempts.
    > Please advise. Thanks!!
    >
    > 1) html submit button, most commonly used.
    >
    > <form name="formName" action="url" method="post">
    > <input type="submit">
    >
    > 2) html regular button, and a JavaScript to invoke the form.submit()

    method
    >
    > <form action="url"
    > function submitForm()
    > { file://etc...
    > formName.submit();
    > }
    > <input type="button" onClick="submitForm()">
    >
    > 3) onsubmit event handling
    > <form name="formName" action="url" method="post" onsubmit="return
    > submitForm()">
    > function submitForm()
    > { file://etc...
    > file://formName.submit(); file://NOT NECESSARY!!
    > }
    > <input type="submit">
    Jeff Thies, Jun 26, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    6,170
  2. Matt

    Submit Form Data Approaches

    Matt, Jun 26, 2004, in forum: ASP General
    Replies:
    2
    Views:
    106
    Bob Barrows [MVP]
    Jun 27, 2004
  3. Matt

    submit form data approaches

    Matt, Jun 26, 2004, in forum: Javascript
    Replies:
    0
    Views:
    66
  4. Replies:
    2
    Views:
    343
  5. Replies:
    3
    Views:
    654
Loading...

Share This Page