NoUser2U 0 Posted June 14, 2011 Report Share Posted June 14, 2011 (edited) Dear all,For some time now i'm using the <form> element in this matter:<form method="post" action=?controller=example1&method=example2>I'd like to send data via the 'GET method', but it is essential that the querystring is placed AFTER the action, for example, let's say i have: <form method="get" action="?controller=search&method=getinput"> <input type="text" name="input" /> <input type="text" name="input2"> ... some more inputs etc. etc. ... <input type="submit" value="Submit" /></form> Now what i'd like to have is, after pressing the submit button, my url to look like: "http://example.com?controller=search&method=getinput&input=...&input2=....&etc etc etcThe way it is right now is, when i press the submit button, the url will look like: "http://example.com?input=...&input2=...It somehow completely ignores the 'action' attribute specified in the <form> element.How do i solve this? Thnx in advance! Edited June 14, 2011 by Donotknow Quote Link to post Share on other sites
Ingolme 1,021 Posted June 14, 2011 Report Share Posted June 14, 2011 You have to add the parameters as inputs of the form. Leaving the action empty will send the form to the same page. <form method="get" action=""> <input type="hidden" name="controller" value="search" /> <input type="hidden" name="method" value="getinput" /> <input type="text" name="input" /> <input type="submit" value="Submit" /></form> Quote Link to post Share on other sites
NoUser2U 0 Posted June 14, 2011 Author Report Share Posted June 14, 2011 (edited) Thnx for your fast reply Ingolme,I had thought of that and tried it, which worked, but is that the only way possible?How do other sites do it? for example, when you fill in a form and press enter. Then the site redirects you to some page and you see a very long dynamically generated url. It's hard to imagine such a site has a whole load of hidden fields in order to generate the custom url, right?In other words: is there no other 'clean and correct' way to do it? Edited June 14, 2011 by Donotknow Quote Link to post Share on other sites
Ingolme 1,021 Posted June 14, 2011 Report Share Posted June 14, 2011 Thnx for your fast reply Ingolme,I had thought of that and tried it, which worked, but is that the only way possible?How do other sites do it? for example, when you fill in a form and press enter. Then the site redirects you to some page and you see a very long dynamically generated url. It's hard to imagine such a site has a whole load of hidden fields in order to generate the custom url, right?In other words: is there no other 'clean and correct' way to do it?They possibly have PHP scripts to generate HTML for the fields.That's the only way to add parameters to the query string in a form using the GET method. Quote Link to post Share on other sites
NoUser2U 0 Posted June 14, 2011 Author Report Share Posted June 14, 2011 Ooh i see, Thank you for your input, i will adapt to the way of inputting hidden fields! Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.