0
<input name="KeywordBox" class="BasicSearchInputBox" type="text" value="Keyword Search..."/>
<div class="searchBtnHolder"><a class="searchButton" href="#" type="submit"><span>Search</span></a></div>

I need to keep the user input text in the inputbox even after submit. When user submits, what happens is the value of inputbox is grabbed and added to the URL as querystring like mysite.com/index.aspx?kwd=userinput..

But it would be nice if we could keep what the user typed in so they know what they typed in and don't have to wonder!! Using jquery, is it possible? Can we not grab the value back from the url and set it back in the inputbox??

2
  • What are you using using for the back end? (ASP.Net ,MVC... ?) Commented Jan 6, 2012 at 3:34
  • The answer will be virtually the same as to your own question on how to do the same thing with a select element: stackoverflow.com/q/8737025/615754 or your question (with an accepted answer!) on how to do the same thing with a radio button: stackoverflow.com/q/8736869/615754. I don't want to get too snippy about it, but will you be posting a question about how to do this for every input type? Commented Jan 6, 2012 at 3:43

1 Answer 1

0

You can submit the form without doing post back using jquery post. Then it will not remove the user entered content. http://api.jquery.com/jQuery.post/

$('#yourButtonId').click(function(){
  $.post('ajax/test.html', $('#yourFormId').serialize() ,function(data) {
      //call back function
      alert(data);
   });

});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.