very simple question about an input box..

Discussion in 'JavaScript' started by sercan, Sep 7, 2008.

  1. #1
    i have a code like this but it's not working:

    i want to go the search page with the search term entered to textbox without using form.. how can i use this.. (i have a website with frames that's why i wrote like "top.main")

    i know it is simple but i am missing something.. :/
     
    sercan, Sep 7, 2008 IP
  2. zerxer

    zerxer Peon

    Messages:
    368
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You need to put id="search_term" in your text input as well since you're using document.getElementById on it.
     
    zerxer, Sep 8, 2008 IP
  3. sercan

    sercan Well-Known Member

    Messages:
    204
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    123
    #3
    i tried but.. still, it is not working.. there is a problem with the code.. i am not sure if it is true or not.. how can i read the value of that text box?? are there any other ways to do this?
     
    sercan, Sep 8, 2008 IP
  4. MMJ

    MMJ Guest

    Messages:
    460
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #4
    <input type="text" name="search_term" id="search_term">
    <input type="button" onclick="top.main.location.href='search.php?x='+escape(document.getElementById('search_term').value)"> 
    HTML:
     
    MMJ, Sep 8, 2008 IP
  5. zerxer

    zerxer Peon

    Messages:
    368
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Oh yeah.. you forgot the closing parenthesis for escape(). MMJ's should work.
     
    zerxer, Sep 8, 2008 IP
  6. sercan

    sercan Well-Known Member

    Messages:
    204
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    123
    #6
    yea, it should be workin now.. thanks for your support.. ;)
     
    sercan, Sep 8, 2008 IP