get selected content from ajax search result [duplicate] - php

This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
adding content from search result with jquery
I'm using this nice script http://qpoit.com/marcofolio_demo/apple_search/ however I want to display the selected value in a div with $.("#result").html(selectedValue); but I don't know how to get the selected value after the search results appear. Please help

If you want to display the text for the search result which appears in the <span> tag:
// Place inside the keyup method used for triggering AJAX call
$('#searchresults a').mouseenter(function() {
$('#result').text($(this).children('.searchheading').text());
}).mouseleave(function() {
$('#result').text('');
});

Related

My form element disappears when id="..." is added to the tag [duplicate]

This question already has answers here:
AdBlock plus hids elements with ids or class with the word "ad"
(2 answers)
Closed 3 years ago.
As per the title, )I have a form that needs and id beacuse of the textarea element. However, just adding the id makes the form disappear completely.
Code before disappearance:
View before disappearance:
Code when id is added:
Refreshed page:
Does anyone have a clue? I don't even know where to start looking for a solution, this seems so ridiculous. The newAd is unique id within the scope of the project, not just the page, and is only referenced in code within textarea's form attribute.
Your ad blocker is likely causing the issue, since the id contains the word ad.
See this Q/A - AdBlock plus hids elements with ids or class with the word "ad"

Anyone know how I would send form data without page refresh? [duplicate]

This question already has answers here:
How to send form data without page refresh?
(6 answers)
Closed 4 years ago.
I have a form sending chat messages to database and a php file getting them on a page as styled elements I use ajax to get messages from my php file and display them every 2 seconds.
The only problem is that when the form is submitted, it refreshes the page.
Which is quite annoying.
Anyone know how I could get data to the database without the page refreshing?
Submit your form with a button that is not an input of type submit and call a javascript function in the onclick event that makes an ajax call. That will prevent the page from refreshing.

Is it possible to use $_POST from an anchor? [duplicate]

This question already has answers here:
How do you force a web browser to use POST when getting a url?
(11 answers)
Closed 8 years ago.
I'm working on a retail type website and I have the search bar so that when you search for something it shows up in a grid with all the results. Now, all the product names are going to be links that all lead to the same page (result.php) which is full of variables which are filled with the information of the product that was clicked. How would I go about doing something similar to
$name = $_POST['productname'];
but with an anchor tag instead of a text input so I can use it to pull the MySQL data to fill in the page. Is something like this possible?
Click
if(isset($_GET['variablename'])) {
echo $_GET['variablename'];
}
if you use query string in anchor tag you cannot use $_POST.

Inserting line breaks in mysql from a form [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Preserve Line Breaks From TextArea When Writing To MySQL
I have created a form that is inserting data into mysql database but I would like the form to insert line breaks (when I press the return key) into the database from the form so I can have paragraphs when displaying the information from the database. At the moment information from the database is just displaying as all in one line despite pressing the return button on the form (text area) when entering the info.how can I do this? I am using php and am quet new so please help.
You need a <textarea> div , then you will be able to capture the new lines, from there you can just get the input you need via normal $_GET or $_POST
What i am guessing is that you just echo the output from the database, use <pre></pre> for formatting your output or nl2br function of php.

Using PHP and Javascript to Reload Data [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Loading Content using Ajax with PHP Include
So, I have a bit of a problem. I have a page, and in the page is a div, and in the div is an include for php. It includes a page that actually populates the div with content. Now, my issue is I want to make it so the div will refresh with more content loaded up from a MySQL server. My problem is going from the anchor link in the page, and using a (what, probably ajax I think?) call to a php function to load more content from the database. Thanks to any help anyone can give!
render a javascript snippet which will do a ajax post on click of that anchor. in that php, replace the div's innerHTML with the content you loaded from Mysql.
`jQuery(div_id).html(content)`
will replace the div's html with content.

Categories