html, send a form via post or get according to submit button -


i wonder if there clean way html form posted if user pushes post button , sent method if user pushes button. need because show form can both enter new data or search existing data in database. if user wants enter data in database fill form , send via 'send' button (post) , if not sure want can partly fill form , push search button (get) receive insights on in database. know method defined form, not submit buttons. idea how without javascript? or javascript?

although shouldn't need functionality, answer question anyway.

here. first should assign id form. our sample form have id 'yyyy'.

<form action="whatever" id="yyyy" method="" >    <input type="button" onclick="usingget();" value="get" /> <input type="button" onclick="usingpost();" value="post" />  </form>   <script type="text/javascript"> function usingget() { document.getelementbyid('yyyy').method = 'get'; settimeout(function(){ document.getelementbyid('yyyy').submit(); }},1000); function usingpost() { document.getelementbyid('yyyy').method = 'post'; settimeout(function(){ document.getelementbyid('yyyy').submit(); }},1000); </script> 

now, when click 1 of buttons change method. edit: there 1 second delay because tired , unsure of whether or not form submit before method changed without it.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -