I want to write some javascript where
[LIST]
The user inputs a search term into a text box
[LIST]
The user presses the submit button & parses the user-input to a function
[LIST]
Data is displayed on the page
[LIST]
The user can enter a second seach term & presses the same button
[LIST]
the page is refreshed and the function runs again with the user input & displays different data
(i hope that makes sense)
I’ve written the following code:
//called when the refresh button is pressed
function refreshPage(){
history.go(0);}
//called when the search button is pressed
function changeText(){
searchTerm = document.getElementById(‘searchTerms’).value;
$(document).ready (function(){
var url = “
+ searchTerm+ “&rpp=15&callback=?”;
…
});
The code works but is clunky & requires 2 buttons. It seems the nested function “$(document).ready (function(){” will not run a second time. The page needs to be refreshed and then changeText() called again.