Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Anyone...Search Results via href link?

Posted on 2012-12-23
3
Medium Priority
?
272 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 1500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer…
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…
Suggested Courses

926 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