0

I posted this once but no one is stopping by so maybe the title didn't sound much interesting.

I got the code for a google search bar and pasted it on the corresponding <div id and made a separate file for the search results and worked perfectly.

But when I tried to put the search bar code in a php file and include it in my pages <?php include("php/google_search_bar.php"); ?> it does not show the search bar. It shows only the word "Loading" which is found here:

<div id="cse-search-form" style="width: 100%;">Loading</div>
<script src="../../Documents/jsapi" type="text/javascript"></script>... etc.

but the input box and search button are not loaded in the webpage.

**Note that the code itself it's correct because if I copy and paste it back directly into the <div id="searchbar.php"> the whole search bar re-appears and fully functional.

google_search_bar.php only contains the source code provided by google when the search bar was created. Do I need to add any more code so it shows up at <?php include("php/google_search_bar.php"); ?> ?

Thank you for your help!

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by almostbob
0

means the program has not found the javascript to replace the innertext of the div
likely causes

wrong filename the script is unlikely to be called jsapi, more often jsapi.js

the path is wrong ../../Documents is not the path to the script from the file that is including, try absolute references <script src='http://yoursite/documents/jsapi.js'> or <script src='<?php echo $_SERVER['DOCUMENT_ROOT'].'/documents/jsapi.js'; ?>' type='text/javascript'>

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.