4 Replies - 283 Views - Last Post: 05 February 2012 - 11:11 PM

Topic Sponsor:

#1 deathmeat  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 72
  • Joined: 25-August 10

perform submit function without form

Posted 05 February 2012 - 10:53 AM

so heres the thing. I have noticed on websites that instead of having <input type="submit"> they have <button type="button"> and when user clicks on the button it goes to a new page such as Edit page. how can it be done?
I mean i do know jquery.form submit function which when user clicks on a button type submit it goes to the directed page.
but they dont use <input type="submit"> , how can it be done ?
<button type="button" class="me" onclick=";return false;" role="button">


Is This A Good Question/Topic? 0
  • +

Replies To: perform submit function without form

#2 deathmeat  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 72
  • Joined: 25-August 10

Re: perform submit function without form

Posted 05 February 2012 - 11:18 AM

so heres the thing. I have noticed on websites that instead of having <input type="submit"> they have <button type="button"> and when user clicks on the button it goes to a new page such as Edit page. how can it be done?
I mean i do know jquery.form submit function which when user clicks on a button type submit it goes to the directed page.
but they dont use <input type="submit"> , how can it be done ?
how can send data like to edit.php when user clicks on
<button type="button" class="me" onclick=";return false;" role="button">
without using ajax!
Was This Post Helpful? 0
  • +
  • -

#3 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 3239
  • View blog
  • Posts: 10,644
  • Joined: 18-April 07

Re: perform submit function without form

Posted 05 February 2012 - 12:33 PM

There are multiple ways using jQuery or even straight vanilla Javascript. The button is just used as the element to kick off the event which will trigger functions in the Javascript.

For instance here is an example where we submit a form called "myForm" using the button and jQuery...

$(":button").click(function () {
    document.Forms['myForm'].submit();
});



You can also attach events to elements in regular straight Javascript using methods like addEventListner() (the W3C method) or attachEvent() (the IE method) or through selecting the element and setting its property to a handler like someElement.onclick = methodnamehere;.

There are many ways you can kick off the click event from the button without needing to have a direct submit button. If you can kick off the event from the button then you can simply submit the form like I show above.

Hopefully I have made this clear. Look up some of the methods I have mentioned here for further information. :)
Was This Post Helpful? 0
  • +
  • -

#4 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 2147
  • View blog
  • Posts: 5,431
  • Joined: 08-June 10

Re: perform submit function without form

Posted 05 February 2012 - 11:05 PM

it can be done using Javascript/jQuery. if you submit the form programmatically, it doesn't matter which element triggers that.
Was This Post Helpful? 0
  • +
  • -

#5 modi123_1  Icon User is offline

  • Suiter #2
  • member icon


Reputation: 3561
  • View blog
  • Posts: 14,989
  • Joined: 12-June 08

Re: perform submit function without form

Posted 05 February 2012 - 11:11 PM

Please do not open duplicate topics.. thanks!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1