I am writing a code to do a google search. i am actually appending the string to the end of the google search string

<body>
  <form name="f" action="http://www.google.lk/search?" target="name3">
    <input  name="name1" type="hidden" value="">
  </form>
  <center>
  <iframe name="name2" width="100" height="300" src="somePage.html" target="name3"></iframe>
  <iframe name="name3" width="100" height="300"></iframe>
  </center>
</body>

This code works, but it displays 10 search results, what i want to do is to display only 5 search results. So the google search string to do that is;

http://www.google.lk/search?q=THESEARCHSTRING&num=5&

So what i have to do is, to append the search string which is "THESEARCHSTRING" in between http://www.google.lk/search? and &num=5&

How do i code this ?

help appreciated ?

Member Avatar for diafol
<form name="f" action="http://www.google.lk/search?" target="name3">
    <input  name="name1" type="hidden" value="">
    <input type="hidden" id="num" name="num" value="5" />
  </form>
<form name="f" action="http://www.google.lk/search?" target="name3">
    <input  name="name1" type="hidden" value="">
    <input type="hidden" id="num" name="num" value="5" />
  </form>

I am using iframes here, so how do i fix it to an Iframe ?

Member Avatar for diafol

You don't seem to have an input box for search term nor a submit button. I assumed you were dealing with ajax of some description. How do all your iframes work? I'm a little confused. Where's the php?

//Anyway, I have never tried the num parameter before. I gave it a go, but it doesn't seem to work. How about you? I set num to all kinds of different numbers, but I just get the same old results (everything).

</head>
<body>
<form>

<input type="text" name="query"  >

					  
<input type="button" id="mysubmit" value="Search ">
</form>
</body>
</html>

This is the file that is in the somePage.html (this is in a IFRAME). and once the SEARCH button is clicked it would show the result in the other IFRAME.

I need to restrict the search to 5 items, and not 10 which is the default

Member Avatar for diafol

Your Sri Lankan designation works well - doesn't work with co.uk or com. :(

<form name="f" action="http://www.google.lk/search?" target="name3">
    <input type="text" id="q" name="q" />
    <input type="hidden" id="num" name="num" value="5" />
    <input type="submit" value="go" />
</form>

Works for me (haven't tried the iframe stuff though).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.