Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I've seen sites where instead of form buttons, they use links like that
onclick="USER._like('161', this);"
And when I click on it, it dynamically inserts the data into the database.
What is this called? And are there any tutorials around here?
Thanks.
That is a javascript event handler. Presumablly the function USER.like ( or to be exact the method like on the object USER) makes an ajax call and sends the value 161 to the server which is then somehow recorded.
That said its much better to do it in an unobtrusive manner, meaning that you would not write function call into an html attribute but rather attach an even handler pragmatically from javascript... using assuming this html:
<a class="like-button" href="#" data-id="161">Like</a>
Achieving the same thing in an unobtrusive manner with jquery would look like:
$(function (){
$('.like-button').on('click', function (e) {
e.preventDefault();
USER.like($(this).attr('data-id'), this);
});
});
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I need to be able to have my main page (index.php) check every 10 seconds for a change in the mysql database table 'refresh'. If the 'refresh' value is 1 it needs to refresh the page in its entirety. If the value is zero it does nothing. I would use meta-refresh but I cannot have the page always refreshing as the page has a slider and it would mess up the rotation. Please let me know what you think of! Thanks in advance!
Use AJAX to check if an update is required.
http://api.jquery.com/jQuery.ajax/
You should learn the basic how to's of AJAX before using something like jQuery when you don't even know what's going on.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
http://www.aliexpress.com/item/NEW-7-Android-2-3-256MB-DDR2-4GB-NAND-Flash-7-inch-tablet-pc/498159194.html - I got this link
Here you can see a buttons: bundle, color
If you click some of them the price will change, but the question is how can I parse that behaviour to my page via php?
The problem is that I can't understand where is javascript code that executes this, or how to find it, maybe someone got ideas about that?
Inspecting that page's source code I can see that the skuProducts variable in javascript contains this information encoded into a JSON-string. You can't really run this javascript code on your webserver, so you'll have to devise another way to get that variable's value - and then you can use json_decode() to get the contents.
Note that changing the amount of items results in an AJAX call to a shipping costs calculator. You could probably simulate that, but I'm not sure that webshop would like that (and it might be illegal).
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
This is probably terribly simple. I have done something similar to this when the information was being passed to a different page.
Basically... I have a div with a dynamically generated list of objects.
<li><?= $array['City'] ?></li>
All of the code already exists to load the zip codes for a given city, so in PHP (in this case)
$locations = new ProjectsLocationsArrays();
$zipcodes = $locations->array_zips($array['City']);
At present, everything runs off of query strings... ?city=aaa&zip=123, seems sloppy to me. I would like to use AJAX. Once the cities are loaded, how do I load the zips into an existing div on the page, fired by a click on one of the city anchors.
TIA
If you have jQuery something like this should work
function loadZipCodes(city){
$.ajax({
url: "pagethatgivesarrayofzipcodes.php",
method: "POST",
data : {'city': city}
}).done(function(data) {
$(.zip-div).html(data);
});
}
Where pagethatgivesarrayofzipcodes.php takes a $_POST['city'] containing the city info and returns either HTML or a a Javascript array of ZIP codes.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I would like to know how you add a function that clears the contents in the textarea if something is typed. For example, the standard message in the textarea would say: "Type something...", but if something is typed, the textarea would be cleared. Basically, the same function that Facebook uses in their wallpost-textarea.
And how do I make the height of the textarea automatically follow the amount of text, so no scrollbar is needed. Again, the same function that Facebook uses in their wallpost-textarea.
Actually, I've noticed that the function that clears the contents in the textarea/input field is used on this site's signup page, when you entering your e-mail, password etc.
I hope that some of you can help me. I've tried to find a script about it but without any luck!
The first thing is a (HTML5) placeholder attribute. It is a message that is there by default and when you start typing it goes away.
http://www.w3.org/html/wg/drafts/html/master/forms.html#the-placeholder-attribute
For the second one you need some JavaScript.
$('textarea').on('keyup',function(e){
$(this).css('height',$(this).get(0).scrollHeight);
});
Probably not the best solution but you could try something like the following.
<script>
function textAreaAdjust(o) {
o.style.height = "1px";
o.style.height = (25+o.scrollHeight)+"px";
}
</script>
<textarea cols="50" id="textAreaAdjust" style="overflow:hidden" placeholder="Type something..." onkeydown="textAreaAdjust(this)"></textarea>
jsfiddle example
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
how do I force a user to go back twice on a mobile web page using PHP or jAVASCRIPT without the user clicking any link or button.
something like using history.back() without a user having to click on anything
In javascript
function goBackTwice()
{
window.history.go(-2)
}
You may want to look into https://github.com/browserstate/history.js/ for a more robust client side solution.