Does anyone know the code to insert into a standard AJAX Google News Bar code which would allow a user to input a name from which to have the News Bar search.
Currently, the News Bar code only searches out names entered as the "name" within the code itself entered by the programmer. Looking for a way to allow users to input a name from the News Bar itself.
EG- Input Box Displays News
Current coding is: - <script type="text/javascript">
-
function LoadNewsBar() {
-
var newsBar;
-
var options = {
-
largeResultSet : true,
-
title : "In the news",
-
horizontal : true,
-
linkTarget : GSearch.LINK_TARGET_BLANK,
-
autoExecuteList : {
-
executeList : ["keyword"]
-
}
-
}
-
-
newsBar = new GSnewsBar(document.getElementById("newsBar-bar"), options);
//-->where "keyword" can be any word
Would like to be able to allow the web page user to enter the keyword to search within the News Bar itself...
Thanks...
3 2131
If I'm following correctly, a text box which the user uses to input the keyword which you pass to the LoadNewsBar function: - function LoadNewsBar(keyword) {
and that's used in place of "keyword":
That doesn't work: and I haven't seen any code whereby any word is entered between the brackets after LoadNewsBar. The brackets are supposed to be empty The matter seems to be a simple one- yet I'm not an AJAX code writer. All I want to be able to do is have the user enter a keyword to search news by in the News Bar, rather than have the keywords being static as designated within the coding. Thanks for your reply, though...
So for example the below code is the ajax code to create a search box for the user to do a google search- and I would imagine that this code can be integrated into the NewsBar code to do what I'm looking to do: - google.load('search', '1');
-
-
var imageSearch;
-
-
function addPaginationLinks() {
-
// The cursor object has all things to do with pagination
-
var cursor = imageSearch.cursor;
-
var curPage = cursor.currentPageIndex; // check what page the app is on
-
var pagesDiv = document.createElement('div');
-
for (var i = 0; i < cursor.pages.length; i++) {
-
var page = cursor.pages[i];
-
if (curPage == i) { // if we are on the curPage, then don't make a link
-
var label = document.createTextNode(' ' + page.label + ' ');
-
pagesDiv.appendChild(label);
-
} else {
-
// If we aren't on the current page, then we want a link to this page.
-
// So we create a link that calls the gotoPage() method on the searcher.
-
var link = document.createElement('a');
-
link.href = 'javascript:imageSearch.gotoPage('+i+');';
-
link.innerHTML = page.label;
-
link.style.marginRight = '2px';
-
pagesDiv.appendChild(link);
-
}
-
}
-
-
var contentDiv = document.getElementById('content');
-
contentDiv.appendChild(pagesDiv);
-
}
-
-
function searchComplete() {
-
// Check that we got results
-
if (imageSearch.results && imageSearch.results.length > 0) {
-
// Grab our content div, clear it.
-
var contentDiv = document.getElementById('content');
-
contentDiv.innerHTML = '';
-
-
// Loop through our results, printing them to the page.
-
var results = imageSearch.results;
-
for (var i = 0; i < results.length; i++) {
-
// For each result write it's title and image to the screen
-
var result = results[i];
-
var imgContainer = document.createElement('div');
-
-
var title = document.createElement('div');
-
// We use titleNoFormatting so that no HTML tags are left in the title
-
title.innerHTML = result.titleNoFormatting;
-
-
var newImg = document.createElement('img');
-
// There is also a result.url property which has the escaped version
-
newImg.src = result.tbUrl;
-
-
imgContainer.appendChild(title);
-
imgContainer.appendChild(newImg);
-
-
// Put our title + image in the content
-
contentDiv.appendChild(imgContainer);
-
}
-
-
// Now add the paging links so the user can see more results.
-
addPaginationLinks(imageSearch);
-
}
-
}
-
-
function OnLoad() {
-
// Our ImageSearch instance.
-
imageSearch = new google.search.ImageSearch();
-
-
// Restrict to extra large images only
-
imageSearch.setRestriction(google.search.ImageSearch.RESTRICT_IMAGESIZE,
-
google.search.ImageSearch.IMAGESIZE_MEDIUM);
-
-
// Here we set a callback so that anytime a search is executed, it will call
-
// the searchComplete function and pass it our ImageSearch searcher.
-
// When a search completes, our ImageSearch object is automatically
-
// populated with the results.
-
imageSearch.setSearchCompleteCallback(this, searchComplete, null);
-
-
// Find me a beautiful car.
-
imageSearch.execute("Subaru STI");
-
}
-
google.setOnLoadCallback(OnLoad);
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Renie83 |
last post by:
Hi I really am going crazy!
I'm using VBScript, ASP, and SQL
My page reminds me of a shopping cart but looking at shopping cart
examples has not helped!
What I have is a page that brings in...
|
by: Ray Lavelle |
last post by:
I'm new to VB .NET. In the past when creating an application, if I
had an input form I would just call the set and get methods on the
object that mapped to my database table in order to store and...
|
by: agent349 |
last post by:
Hi,
I'm fairly new to c++. I need user input in the form of dollar
amounts, ie: "$10.00". I'd like to remove the dollar sign "$" then
store the rest in a variable. How do I go about removing the...
|
by: Clare |
last post by:
Hi
I have a report that is made of 4 subreports. There is no actual
information in the main report, and the record source is empty. In
the Header section of the main report, I have a text box...
|
by: Daniel Walzenbach |
last post by:
Hello,
I want to create a Word XML file based on the input users make in a VB.NET application. I imagine creating a template in Word and saving it as a XML file. I then want to fill the...
|
by: josephm |
last post by:
Hello Group:
My first post on the group.Hope I get a response.
I have a modest Fire Insurance ACCES Db.Thanks to this group - for the
code. A "wanna be programmer"... "LEARNS"
The code...
|
by: chuck |
last post by:
I need some help with validating user input. I am writing a C computer
program for an intro to C course. Here is the situation. I am
creating an application that will do currency conversions. ...
|
by: ecpbm765 |
last post by:
Hey,
I am helping to develop a project that displays images based on user
input. One possible way of implementing this is via a widget that
when it is run, would read in the users input from an...
|
by: phl |
last post by:
hello,
I am trying to explore options on the various types of search engines
for searching user input. User input maybe stored in XML files. Does
anyone know if there are any good ready made...
|
by: John c |
last post by:
I have looping code in Access which generates Excel spreadsheets and prints them off. They can run to hundreds and at present, once the code starts to run there is no way it can stop cleanly part...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |