type a string save it as a variable and then add it to another string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Alino
    New Member
    • Aug 2009
    • 25

    type a string save it as a variable and then add it to another string

    hello, could you help me please solve this problem?
    I need to make a form with just one text field, but javascript will save that typed string into that text field as a variable 'X'. After clicking a form button, it should open the google search page with searching the following "Alino is watching 'X' haha"
    So if user has typed "blablabla" it should open the google search with this query in it "Alino is watching blablabla haha".
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    you might use the replace() method for such a purpose:

    Code:
    var s = "Alino is watching X haha";
    var newTextForX = 'foo';
    
    alert(s.replace('X', newTextForX);
    kind regards

    Comment

    • larztheloser
      New Member
      • Jan 2010
      • 86

      #3
      You might also want to check out http://code.google.com/apis/customsearch/docs/api.html

      Comment

      • Alino
        New Member
        • Aug 2009
        • 25

        #4
        thank you, this was very useful information.

        Comment

        Working...