/    Sign up×
Community /Pin to ProfileBookmark

Getting user input & refreshing page

I want to write some javascript where

[LIST]

  • The user inputs a search term into a text box

  • [/LIST]
    [LIST]
  • The user presses the submit button & parses the user-input to a function

  • [/LIST]

    [LIST]
  • Data is displayed on the page

  • [/LIST]

    [LIST]
  • The user can enter a second seach term & presses the same button

  • [/LIST]

    [LIST]
  • the page is refreshed and the function runs again with the user input & displays different data

  • [/LIST]

    (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 = “http://search.twitter.com/search.json?q=
    + 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.

    to post a comment
    JavaScript

    0Be the first to comment 😎

    ×

    Success!

    Help @candyBikerBabe spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 6.17,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @nearjob,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,
    )...