Pass text to a url through input form

MultiformeIngegno

  • Posts: 1,337
Re: Pass text to a url through input form
« Reply #15, on April 28th, 2013, 03:29 PM »
The form works properly on every browser if you click the "Go" button (<input type="button">). It doesn't if I fill the input type="text" and press ENTER on my keyboard (or for example push the "Go" button in iOS keyboard). So: it works if I push the input type="button", not if I press ENTER from keyboard. How can I make it work that way too?

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Pass text to a url through input form
« Reply #16, on April 28th, 2013, 04:06 PM »
Attach it to an onsubmit event of the form as a whole rather than the go button's onclick event then it'll trigger before going to another page.
When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest. | Game Memorial

MultiformeIngegno

  • Posts: 1,337
Re: Pass text to a url through input form
« Reply #17, on April 28th, 2013, 04:09 PM »
Uhm, I tried with this but didn't work:

   <form onsubmit="calcRoute();reducemap();" id="percorsoform" style="display:none;top:-3px;position:relative">
      <input type="text" id="start" name="start" placeholder="Indirizzo di partenza" style="margin-left:5px;width:200px">
      <input type="submit" value="Vai">
   </form>

http://ffio.it/map.html

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278

MultiformeIngegno

  • Posts: 1,337
Re: Pass text to a url through input form
« Reply #19, on April 28th, 2013, 04:27 PM »
Quote from Arantor on April 28th, 2013, 04:20 PM
Define 'didn't work'
Right! :D
If you go to http://goo.gl/wr3qi (live site), click on "calcola percorso", enter an address (example: "Via Eugenio Checchi, Roma") and push the Vai (Go) button, the route is built. If you enter the address and instead of the button you press ENTER, the page is reloaded.

Now with onsubmit the page is reloaded both if I press ENTER and if I push the Go button: http://ffio.it/map.html

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Pass text to a url through input form
« Reply #20, on April 28th, 2013, 04:30 PM »
At the end of the onsubmit event, return false. You don't want the page to be reloaded, so that's the way to do that.

The only reason it didn't get reloaded before is because you're not using input type="submit" which would do that.

MultiformeIngegno

  • Posts: 1,337
Re: Pass text to a url through input form
« Reply #21, on April 28th, 2013, 04:32 PM »
Quote from Arantor on April 28th, 2013, 04:30 PM
At the end of the onsubmit event, return false. You don't want the page to be reloaded, so that's the way to do that.

The only reason it didn't get reloaded before is because you're not using input type="submit" which would do that.
Yup! onsubmit="calcRoute();reducemap(); return false" worked. :D
Re: Pass text to a url through input form
« Reply #22, on April 29th, 2013, 08:51 PM »
This is turning me mad. I'm sure yesterday this worked just fine... Without me changing anything now the form route is calculated only the SECOND time you fill the form and press ENTER. It's non sense.. <_< The first time it seems the form is submitted to the server (note the ?=... after the url)
http://goo.gl/wr3qi (to try you have to click as always on "calcola il percorso" and then enter an address like "Via Eugenio Checchi, Roma", even though it works also with a starting address from London :D )
Posted: April 29th, 2013, 08:49 PM

EDIT: Uhm, no. Now it's working again. Maybe it was just an old version of the page cached.