"Get" method HTML form

Discussion in 'Programming' started by ridesign, Jan 13, 2007.

  1. #1
    Hi,
    I want post the following instructions from my form, using the "Get" Method

    I need to post the following:
    http://www.otherdomain.com/post.aspx?Email=&IPAddress=[IP]&DateTimeStamp=[DATE]

    However I have no idea how to use the GET and post method using the same form.

    Can I add this on my existing form page? also how do put a check box so it only submits this if the box is ticked.

    Thanks
     
    ridesign, Jan 13, 2007 IP
  2. YIAM

    YIAM Notable Member

    Messages:
    2,480
    Likes Received:
    240
    Best Answers:
    0
    Trophy Points:
    280
    #2
    What's problem with POST method. I mean why do you want to use GET method .
     
    YIAM, Jan 13, 2007 IP
  3. ridesign

    ridesign Peon

    Messages:
    294
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I am using the post method to post information to my database however I need to send data to another website and they have specified that I must use the "GET" method
     
    ridesign, Jan 13, 2007 IP
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4
    
    
    <script type="text/javascript">
    <!--
    function fetch_method(form)
    {
         if (form.get.checked)
         {
              form.setAttribute('method', 'get');
              form.setAttribute('action', 'http://new-url.com');
         }
    }
    //-->
    </script>
    
    <form action="your-url.com/" method="post" onsubmit="fetch_method(this);">
    
    ... Your form
    
    <input type="checkbox" name="get" value="1" />
    
    
    </form>
    
    Code (markup):

    Untested but should work. If the checkbox is checked, it will submit the form using GET to the URL specified in the Javascript. If not, it will POST the form to the URL specified in the action attribute.
     
    nico_swd, Jan 13, 2007 IP
  5. ridesign

    ridesign Peon

    Messages:
    294
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hi,
    Thanks for your reply,
    Is it possible to POST every time and only GET if the checkbox is ticked?

    thanks
     
    ridesign, Jan 13, 2007 IP
  6. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #6
    That's exactly what it does...
     
    nico_swd, Jan 13, 2007 IP
    YIAM likes this.