Solved

SharePoint 2007 Search Box

Posted on 2013-01-20
33
453 Views
Last Modified: 2013-08-20
I have a SP2007 subsite.

I added a search box and it has the following search scopes

-
Singapore (default)
This Site: Sentosa
East
West
-

How do I remove all and leave it only with:

This: Sentosa
0
Comment
Question by:sharepoint2013
  • 20
  • 7
  • 3
  • +1
33 Comments
 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 38799832
Hi,

this should work with jQuery but please review the HTML output of your page and adjust the selectors.

<script type="text/javascript">
        $(document).ready(function () {

            var $searchbox = $("select[id$='SBScopesDDL']");
            $searchbox.find("option:contains('Singapore')").remove();
            $searchbox.find("option:contains('East')").remove();
            $searchbox.find("option:contains('West')").remove();
        }); 
    </script>

Open in new window


HTH
Rainer
0
 

Author Comment

by:sharepoint2013
ID: 38799959
Hi Rainer, thanks for the quick response!

I tried and nothing happened, this is my code:

<script type="text/javascript">
        $(document).ready(function () {

            var $searchbox = $("select[id$='SBScopesDDL']");
            $searchbox.find("option:contains('Singapore')").remove();
            $searchbox.find("option:contains('East')").remove();
            $searchbox.find("option:contains('West')").remove();
        });
    </script>

I have attached my page code here as page.aspx

And is it possible to then, remove the dropdown since now its defaulted to:

This Site
0
 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 38799992
Hi,
sorry there is no attachment. Please attach the page source (generated HTML) as text file.

Thanks and KR
Rainer
0
 

Author Comment

by:sharepoint2013
ID: 38800060
Here it is
page.txt
0
 
LVL 14

Expert Comment

by:KoenVosters
ID: 38800206
Go to the site collection settings, and change the search settings to use only the scopes that you want to use.
0
 

Author Comment

by:sharepoint2013
ID: 38800243
@Koen that will affect my main site so i can't use that.
0
 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 38800360
Hi,
I can not find any option inside the HTML which states "Singapore" or West?
Can you perhaps make and attach a screenshot, where the search box is and with the options?
Other question: how did you add the search box / what search box did you add?

Thanks and KR
Rainer
0
 

Author Comment

by:sharepoint2013
ID: 38800728
I added the default Search box from the webpart list, didnt change any options.

The options are from the site collection settings.

Is the code correct?
0
 

Author Comment

by:sharepoint2013
ID: 38806779
Please assist. Thanks!
0
 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 38807363
Hi,
in your question you said you want to remove the options
- Singapore (default)
- East
- West

In your attached HTML code, there are two search boxes:
- the one from the top (web part id WebPartWPQ1)
<select name="ctl00$PlaceHolderSearchArea$ctl01$SBScopesDDL" id="ctl00_PlaceHolderSearchArea_ctl01_SBScopesDDL" title="Search Scope" class="ms-sbscopes">
						<option value="This Site">This Site: K1 PvB</option>
						<option selected="selected" value="http://k1.zone1.company.com/sites/sg/search/results.aspx">K1SG</option>
						<option value="http://k1.zone1.company.com/sites/sg/search/results.aspx">Promotions &amp; Campaigns</option>
						<option value="http://k1.zone1.company.com/sites/sg/search/results.aspx">Processes</option>
						<option value="">Forms Checklists Letters</option>
						<option value="">Policies DOA Terms &amp; Conditions</option>
						<option value="">Tools and Calculator</option>
						<option value="">System Guide</option>
						<option value="">Pricing Rates &amp; Fees</option>
						<option value="">Contact List</option>
 
					</select>

Open in new window

- the one from the web part added to the page (web part id WebPartWPQ15)
 with the same options (but a different ID)

Therefore both search scope selects do not contain the elements you want to remove - hence the jQuery selector would not find anything.

If you want to remove all entries despite
"This Site: K1 PvB"
only from the scope drop down in the added search box then the jquery will look like this:
<script type="text/javascript">
        $(document).ready(function () {

            var $searchbox = $("select[id$='4dc053104f71_SBScopesDDL']");
            $searchbox.find("option:contains('K1SG')").remove();
            $searchbox.find("option:contains('Promotions')").remove();
            $searchbox.find("option:contains('Processes')").remove();
			$searchbox.find("option:contains('Forms Checklists Letters')").remove();
			$searchbox.find("option:contains('Policies DOA Terms')").remove();
			$searchbox.find("option:contains('Tools and Calculator')").remove();
			$searchbox.find("option:contains('System Guide')").remove();
			$searchbox.find("option:contains('Pricing Rates')").remove();
			$searchbox.find("option:contains('Contact List')").remove();
        }); 
    </script>

Open in new window


HTH
Rainer
0
 

Author Comment

by:sharepoint2013
ID: 38808424
wrong page sorry! but i will try it, thanks!
0
 

Author Comment

by:sharepoint2013
ID: 38808547
Just tried, it didn't work!
0
 

Author Comment

by:sharepoint2013
ID: 38808554
This is the code:

<DIV id=SRSB>
<DIV style="WIDTH: 335px" id=ctl00_m_g_0ab9b6f3_3f16_4fe7_92f9_4dc053104f71><INPUT id=ctl00_m_g_0ab9b6f3_3f16_4fe7_92f9_4dc053104f71_ctl00 value=http://k1.zone1.scb.net/sites/sg/k1_sg/PvB type=hidden name=ctl00$m$g_0ab9b6f3_3f16_4fe7_92f9_4dc053104f71$ctl00>
<TABLE class="ms-sbtable ms-sbtable-ex" border=0>
<TBODY>
<TR class=ms-sbrow>
<TD class="ms-sbscopes ms-sbcell"><SELECT id=ctl00_m_g_0ab9b6f3_3f16_4fe7_92f9_4dc053104f71_SBScopesDDL class=ms-sbscopes title="Search Scope" name=ctl00$m$g_0ab9b6f3_3f16_4fe7_92f9_4dc053104f71$SBScopesDDL> <OPTION value="This Site">This Site: K1 PvB</OPTION> 
..........................

Open in new window

0
 

Author Comment

by:sharepoint2013
ID: 38815481
Rainer, any idea?
0
 
LVL 9

Expert Comment

by:psgindiana
ID: 38828338
Edit the search box web part "Dropdown mode" under "Scopes Dropdown" to "Do not show scopes dropdown, default to contextual scope".
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:sharepoint2013
ID: 38829691
But the search scopes are not removed yet?
0
 

Author Comment

by:sharepoint2013
ID: 38830483
Please assist. Thanks.
0
 
LVL 9

Expert Comment

by:psgindiana
ID: 38831325
I don't understand your question.

Your desired results, from your initial question:
A search box on a subsite that searches for results only in that subsite.
Not allowing users to select a different scope.

The "Contextual Scope" option will set the search to show only results in that subsite. The "Do not show scopes dropdown" will stop users from picking a different scope.
0
 

Author Comment

by:sharepoint2013
ID: 38833995
If I select 'Do not show scopes dropdown' it will search the default scope and not This Site.

If I select 'Show Contextual Scope' it will show the rest of the scopes, which i do not wish it to show.

I like it to show only

This Site.
0
 
LVL 9

Expert Comment

by:psgindiana
ID: 38835584
I apologize. I was looking at a 2010 installation, where there is an option to do both at once.  Sorry to have wasted your time.
0
 

Author Comment

by:sharepoint2013
ID: 38838291
No worries. Anyone knows?
0
 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 38838459
Hi,
sorry have been very very busy on a project.
As I know that the jquery removal works on a couple of customers, can you open the page in IE, save the whole pages as mht file and attach this one?
It must be something with the jquery selector.
Thanks and hth
Rainer
0
 

Author Comment

by:sharepoint2013
ID: 38838640
Here's the page aspx code.

Thanks!!

<link rel="stylesheet" href="System/Styles/main.css"/>
<script type="text/javascript" src="System/Scripts/main.js"></script>


<script type="text/javascript">
$(document).ready(function () {

            var $searchbox = $("select[id$='4dc053104f71_SBScopesDDL']");
            $searchbox.find("option:contains('K1SG')").remove();
            $searchbox.find("option:contains('Promotions')").remove();
            $searchbox.find("option:contains('Processes')").remove();
	$searchbox.find("option:contains('Forms Checklists Letters')").remove();
	$searchbox.find("option:contains('Policies DOA Terms')").remove();
	$searchbox.find("option:contains('Tools and Calculator')").remove();
	$searchbox.find("option:contains('System Guide')").remove();
	$searchbox.find("option:contains('Pricing Rates')").remove();
	$searchbox.find("option:contains('Contact List')").remove();
}); 
</script>

Open in new window

page.aspx
0
 

Author Comment

by:sharepoint2013
ID: 38838643
The script and the page.aspx attached above.
0
 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 38839912
Hi,
I just opened the attached page, modified the path to the jQuery library (because of not having your server paths) and voila - the result is as I expected:

Result
So there are two open questions:
- Why does it not work on your side?
Can you verify that the reference to jQuery is correct? First of all it seems to be a quite old version and second if nothing happens, then it must be that the jQuery call cannot be run

- There is still the discrepancy between your original question and the current code
In your page sample there is no search scope "East" nor "West"....

HTH
Rainer
0
 

Author Comment

by:sharepoint2013
ID: 38854648
I will try with the latest jquery
0
 

Author Comment

by:sharepoint2013
ID: 38892131
Doesn't work though.
0
 

Author Comment

by:sharepoint2013
ID: 38958719
Thanks.
0
 

Author Comment

by:sharepoint2013
ID: 38976633
Any updates?
0
 

Author Comment

by:sharepoint2013
ID: 39010070
Anyone can assist?
0
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 500 total points
ID: 39010496
Hi,
its me again.

Can you please explain again what you want to achieve?
There are two search boxes:
- One on the top above the top navigation
- One in the right column aside the breadcrumb navigation

The provided script just removes the options from the second search box.
And again - in your initial question you mentioned different option entries than the one which are visible in your attached page source.

I have added some debug alerts - what are the results?
<script type="text/javascript">
alert(jQuery);
$(document).ready(function () {
	// Only the second box
	var $searchbox = $("select[id$='4dc053104f71_SBScopesDDL']");
	alert($searchbox);
	alert($searchbox.html());
	$searchbox.find("option:contains('K1SG')").remove();
	$searchbox.find("option:contains('Promotions')").remove();
	$searchbox.find("option:contains('Processes')").remove();
	$searchbox.find("option:contains('Forms Checklists Letters')").remove();
	$searchbox.find("option:contains('Policies DOA Terms')").remove();
	$searchbox.find("option:contains('Tools and Calculator')").remove();
	$searchbox.find("option:contains('System Guide')").remove();
	$searchbox.find("option:contains('Pricing Rates')").remove();
	$searchbox.find("option:contains('Contact List')").remove();
}); 
</script>

Open in new window

0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now