In a form (eg. Search box), like the one at the top right of this page, when I write a word into it and press enter, I can see the search results on the page, but the word I have searched for remains in the box too. Can someone tell me which attribute this is? I can't find one. I am aware that "placeholder" is for the word 'search' in the box before a search is carried out, but how do I ensure the searched word stays in the box after the word is searched for and does not disappear? Thank you!
Asked
Active
Viewed 39 times
0
-
1They're probably grabbing it from the Query string `http://stackoverflow.com/search?q=kjkj` – Christopher Marshall Apr 22 '15 at 15:32
-
You get the search-words from, for example, the url, and use the `value` attribute to put it in the inputbox. – Jordumus Apr 22 '15 at 15:33
-
Thanks Jordumus, that might be doable, can you help me with how? – rjm Apr 22 '15 at 15:53
1 Answers
1
https://stackoverflow.com/search?q=sea
Where q
is GET request parameter. Can be simply access by server side scripting.
Suppose for PHP It's: $_GET
echo $_GET['q'];//sea
You can't do this with simple HTML
. If you aren't using any serverside scripting you can do this with javascript:
-
OK, thank you. So basically if I copy the code of a search box to use with different styling on the same page, I can't make sure the searched word stays in the box, because I can't see the PHP? Unless I use Javascript? – rjm Apr 22 '15 at 15:48
-