Solved

Anyone...Search Results via href link?

Posted on 2012-12-23
3
267 Views
Last Modified: 2012-12-31
Hi I have a Business Catalyst site and found this code here to do what I want to achieve http://www.atlantawebdesignga.com/_blog/Adobe_Business_Catalyst_Developer/post/Use_a_Link_to_Submit_A_Web_App_Search_Results_Page_in_Adobe_Business_Catalyst/:

<script type="text/javascript">
   jQuery(document).ready(function(){
   var theCategory = '{ module_url,category}' ;
   if (theCategory) {
      jQuery('form.webapp option:contains("' + theCategory + '")').attr('selected', 'selected');
      jQuery("form.webapp").submit();
  }
});
</script>

Open in new window



My link is formated as follows:
http://mywebsite.businesscatalyst.com/blog-search-results.html?category=Baubles

Looks just what I need to do, link to search results page with category pre selected . Auto submit the form and have results on the page for the user.
Great and it works but it keeps refreshing/bouncing on the page. Can anyone see a way to stop it submiting more than once?
Help apprectaied.

p.s Merry Christams to you all.

Regards
Lee
0
Comment
Question by:boxhedge
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
jmdl1983 earned 500 total points
ID: 38717089
If the jQuery is causing the loop, then change your jQuery such as:

<script type="text/javascript">
   jQuery(document).ready(function(){
   var theCategory = '{ module_url,category}' ;
   if (theCategory) {
      jQuery('form.webapp option:contains("' + theCategory + '")').attr('selected', 'selected');
      jQuery("form.webapp").submit();
      var theCategory = null;
  }
});
</script>

Open in new window


if it is the page code auto looping when it sees a category in the URL, then simply append the HREF URL to have something such as "&u=1" on the end of it, and only have it auto-submit if request("u")="1", that way it will not be passed to results page.
0
 

Author Comment

by:boxhedge
ID: 38730703
Cheers, Doesn't seems to work, do i have to append the jquery you had in your answers?...anyone else know how to get around this?
0
 

Author Comment

by:boxhedge
ID: 38732260
It does, my mistake. As does my own code but issue was the placement of it.
I was putting it in a sidewide js file where the value { module_url,category} couldn't be parsed. As soon as I placed it in a single page it worked.

Thanks anyway.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

820 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