I have the following javascript
$(document).ready(function() {
$('a[href*="profile"]:contains("David")')
.closest('td').find('.fightMobster').click();
});
This searches the page content for the word 'David' and clicks the link.
I'm wanting to progress this. Instead of searching the page contents, I want to search for the LINK text.
For example, the link to 'David' might be http://www.example.com/164522
So I'd like to search the page for 164522 instead.
Also, I'd like to implement a form where you can specify the text you are searching for. Sort of a text box where you can type 164522 and a button which starts and stops to search process.
In your case you should use
$('a:contains(David)')
Related
I'd like a user to be able to use basic html tags within a textarea and render those tags rather than displaying them as text after the user submits the form. For example, if the users enters
<i>Hi there</i>
and then they click submit, the next page will display their entry into the textarea. What they will see on the next page is Hi there in italics. I've tried this code, but it doesn't seem to work.
$('.blogbody').each(function() {
var string = $(this).html();
$(this).html(string.replace('<i>', '<i>'));
});
Thanks!
I have a website. I want a search box to appear under the main page of my website in google. I have my own custom search engine and search bar in the website. I did a bit of research and found out that you need a chunk of code like this:
<script type=”application/ld+json”>
{
“#context”: “http://schema.org”,
“#type”: “WebSite”,
“url”: “https://www.panpact.com/”,
“potentialAction”: {
“#type”: “SearchAction”,
“target”: “https://query.panpact.com/searchresults.php?search={search_term_string}&page=1&con=1”,
“query-input”: “required name=search_term_string”
}
}
</script>
I have changed the above code to replace example with my website name(Panpact).
I am not sure if it works though. When someone on my site searches and presses enter they are redirected to the search page and the url looks like:
http://panpact.com/searchresults.php?search=Hello&page=1&con=1
First of all is my above Script code correct for what I want to do? And why is their the word query in front of the domain in the target field? Do I need it?
I am designing my own template by making changes to the default template code of OpenCart 2.0.2.0. After repositioning the Search field, it no longer works: it will not submit on pressing Enter, and the search value is not submitted in the URL when clicking the search button in the form (the form submits though).
In order to try and find what goes wrong when relocating the input field, I have made a fresh installation of OpenCart on my WampSever, and without changing anything else, I moved the input field to the main nav, right after the categories UL -- by simply copying the PHP tag that prints the search template:
<?php echo $search; ?>
Nothing else. The form submits on pressing Enter on the keyboard, and it submits on clicking the search button, but the search parameter is no longer appended to the URL, e.g.
http://localhost/opencart/index.php?route=product/search&search=macbook
I need your help to find out why this happens and how I can move the search field without losing its functionality. I suppose this is Javascript related but not sure how.
To answer my own question:
Yes, it is Javascript related. Since the search input field is not wrapped in a , in order to submit it, and get the search query, two jQuery functions have been written (in catalog/view/javascript/common.js, lines 64-81).
These functions get the search input value by first referencing the within which the input is originally located:
[line 68]
var value = $('header input[name=\'search\']').val();
[line 79]
$('header input[name=\'search\']').parent().find('button').trigger('click');
To make it work, I had to replace the two instances of "header" with the ID of the menu:
var value = $('#menu input[name=\'search\']').val();
Sorted then!
Hope this helps some other OpenCart beginner like myself :)
I want to do a page search like Google. This page would contain the following:
a text box
a search button
After I enter a value in the text box and press the button, the result should be put in a DIV but this won't be visible before pressing the search button. The content is to be shown only after pressing the search button. How can achieve this by using jQuery.
Basically, you hide the div using CSS and when hit to search button it appears as follows.
CSS code
#content_div {
display: none;
}
jQuery
$(".search_button").click(function() {
$("#content_div").show();
}
Use jQuery's ajax() function for acheving this.
Check this link: http://www.codeforest.net/simple-search-with-php-jquery-and-mysql
seems like you might want to use something like this:
$('#search_results').load('perform_search.php', {query: $('#search_query_input').val()});
explanation:
#search_results is div where you will put your results
load() is jquery's function to update container via ajax
perform_search.php is the page which will return you results to be displayed in #search_results
query is the name of the parameter which would be passed to perform_search (like 5. $_REQUEST['query'])
#search_query_input is the id of your "text box"
Cheers, hope it will help
I have a form which is using a select list to jump around my site. This is currently using onclick window.location so user selects the page and presses go and it goes to that page.
I now need to add a small text box for the user to type in a code (say 123456) and then when they click go, it should go to the url selected, but with the [CODE] being the number entered in the box. I discovered jquery replaceAll so it gave me the idea to have this in the select html:
http ://jumptothispage.com/parts/p[CODE]/edit
http ://jumptothispage.com/jobs/j[CODE]/edit
When you press go, it would replace all [CODE] in that html with the code entered and then jump to that page selected, e.g.
http ://jumptothispage.com/parts/p123456/edit
http ://jumptothispage.com/jobs/j123456/edit
I am already using jquery on my site so makes sense to try and utilize that again. I'd appreciate a pointer and or other suggestions instead.
Thanks,
Paul.
A workaround: Store the code in a cookie, so at least it's not visible to every person who looks at the URL bar. Then in every onclick, fit it into the URL to send the user to the "right" page.
Or, have your select option's value literally read CODE, which your onclick interprets to mean "The user hasn't set the code yet." When the user types in the code, store it in a variable (in the example below, realcode), and you can then do this:
$('select#navigation option').each(function(idx, el) {
$(el).attr('value', $(el).attr('value').replace(/CODE/, realcode));
});