Quote:
Originally Posted by yazz_1988
Hi sorry to be so late on the follow up questions, i have a couple of things i'd like to ask
why do we need the # sign in the action, what does it do? i see it shows up in the url after i hit enter, but i'm not sure as to why we use it.
Another thing; as it stands the text input gets cleared up since the page reloads, is there any way to maintain the text input past the refresh, i ask this because i want to add another query linked to a button on the frontpage, that will show route a -> route b and route b -> route a, and i would need to $input for the query to work and not have user input it again.
oh and by the way that above solution does work, thanks for that. 
|
To answer your first question: The # sign used in the forms action property is there to make the form submit back to the page it is contained in, or in other words, submit back to itself.
If you don't want the # sign to show up in the URL then change the action property to the name of the file that the form is contained in.
To answer your second question: If you want the value that is entered into the text input element to be there after the page is reloaded then you must reload the value back into the input element.
Something like this:
This should fix your problem.
Note: I don't really want to rewrite your code, but I think if you re-evaluate the way you are using your form, then you should see a way to use it without submitting it by using the onsubmit event listener.
I can't help notice that every time the page reloads it executes the initialize() function.
You could use the forms onsubmit event listener to run a function that would execute the initialize() function without submitting the form.
Then you could also use the same function to execute other tasks as needed.
Just a thought.