www.webdeveloper.com
Results 1 to 7 of 7

Thread: having problem with Java Script

  1. #1
    Join Date
    May 2012
    Posts
    2

    having problem with Java Script

    Hey guys I'm new in Java Script and I'm having some problem.I'm trying to do create one text field where i should type some text and next to it a submit button and when i type something in text field and press submit button a google search for that term should open.
    I tried some code and it is opening google but it is not opening google search for the term that i typed in text field it only opens google homepage.

    <form name="search" action="https://www.google.rs/" method="get">
    Претрага:<input type="text" name="Унос">
    <input type="submit" value="Претражи">
    </form>
    can somebody tell me where is a mistake in my code because i tried many codes and this one is closest to my goal so far.
    Best regards

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,648
    1 not sure but cyrillic in the name value looks unusual
    2 no javascript which problem you're having with present
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

  3. #3
    Join Date
    Nov 2010
    Posts
    1,085
    unsure about the russian site (stupid google keeps redirecting me) but it seems to form the query string correctly you need to rename the text input as padonak says:
    Code:
    <form name="search" action="https://www.google.rs/search?q" method="get">
    Претрага:<input type="text" name="q">
    <input type="submit" value="Претражи">
    </form>
    I would be careful with this, though - google have been known to change the way they parse their query strings - maybe in an attempt to stop people from doing this and force them to use their search API?

  4. #4
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,648
    serbian, not russian ))
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

  5. #5
    Join Date
    Nov 2010
    Posts
    1,085
    oops. извинений / извињење

  6. #6
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,648
    lol )))))))
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

  7. #7
    Join Date
    May 2012
    Posts
    2
    I changed Serbian names into English but it was doing the same thing but i have founded some codes online and modified it a little bit and this one works it's opening google search for typed term.
    Here is the code:
    /////////////////

    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <style type="text/css">
    @import url("layout.css");
    </style>
    <script type="text/javascript">


    function pokreniPretragu() {
    var upit = encodeURIComponent
    (document.getElementById
    ('polje').value);
    window.open
    ('http://www.google.com/search?q=' +
    upit ,'new_window_1');

    }
    </script>

    </head>
    <body>
    <div id="Zaglavlje"><img src="singibleja.jpg" width="750" height="100"></div>
    <div id="Meni">
    <ul>
    <li><a href="index.html">Почетна</a></li>
    <li><a href="html/tabela.html">Табела</a></li>
    <li><a href="html/formular.html">Формулар</a></li>
    <li><a href="css/index.html">CSS</a></li>
    <li><a href="javaScript/index.html">JavaScript</a></li>
    </ul>

    </div>
    <div id="Sadrzaj">
    <form
    onsubmit="pokreniPretragu(); return
    false;">
    <input id="polje" type="text" />
    <input type="submit" value="Претражи"
    />
    </form>
    </div>
    </body>
    </html>
    //////.
    Btw. good Serbian

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles