First TD for next TD

I have: <table> <tr class=”here”> <td class=”first”>first</td> <td class=”next” par=””>next</td> <td class=”next” par=””>next</td> </tr> </table> live: i would like receive with jQuery: <table> <tr class=”here”> <td class=”first”><a href=””>first</a></td> <td class=”next” par=””>next</td> <td class=”next” par=””>next</td> </tr> </table> This must get parameter par from first and make link in first TD with this parameter. Is […]

jQuery variable increment ++ not working in script

I have this jQuery function that switches between different status messages (p elements) with ID’s ranging from status_0 to status_5: setTimeout(function() { var next_status; if (current_status < 5) { next_status = current_status++; } else { next_status = 0; } $(“.status_visible”).fadeOut(“fast”, function() { $(“#status_”+next_status).fadeIn(“fast”); }); //alert(next_status); change_status(); }, 10000); My problem is that to start with, […]

How to safely allow embed content?

I run a website (sorta like a social network) that I wrote myself. I allow the members to send comments to each other. In the comment; i take the comment and then call this line before saving it in db.. $com = htmlentities($com); When I want to display it; I call this piece of code.. […]

Allow calling function to override default options – jQuery UI dialog

I want the callingFunction to be able to override the default options provided in the showDivPopUp function. function calling(){ showDivPopUp(“title of pop up box”, “message to show”, { buttons:{ Yes: function () { $(this).dialog(“destroy”); }, No :function () { $(this).dialog(“destroy”); } } }); } function showDivPopUp(title,msg,options){ var mgDiv = $(“#msgDiv”); mgDiv.attr(“innerHTML”, msg); return mgDiv.dialog({ modal: […]

How do I understand a function that returns a function?

Here’s the example code I’m struggling with: function greaterThan(x) { return function(y) { return y > x; }; } var greaterThanTen = greaterThan(10); show(greaterThanTen(9)); Is there a way to put it in math terms or follow the flow or something? I don’t know why 10 is x and 9 is y.

Site Doesn't Load in IE

My site is loading up perfectly in Firefox, Chrome and other browsers like Safari (albeit a bit slow). Link: It was even working with IE till yesterday but after I compressed my JavaScript code with closure compiler it doesn’t seem to load fully. If I disable JavaScript in IE it opens up but not […]

JSON conversion in javascript

I’m trying to stringify a multi-array variable into a JSON string in Javascript. The //i’m using functions from var info = new Array(max); for (var i=0; i<max; i++) { var coordinate = [25 , 32]; info[i] = coordinate; } var result = JSON.stringify(info); But result doesn’t look like a JSON string at all. What […]

JavaScript – for Loop vs. Array shift

I have two functions, they do look alike but what I don’t really understand is when inside the for-loop, since the input is an array, why doesn’t the array need any index to call the first array? I have an array of… var puzzlers = [ function(a) { return 8 * a – 10; }, […]

“push” is not a function [on elements returned by getElementsByTagName]

I have a bit of Javascript where I’m POSTing my form with an XMLHttpRequest, which otherwise works fine, but when I try to add the SELECT values to the array of INPUT values, it seems Javascript has lost its mind (or I have). This function just builds the “name1=value1&name2=value2” string and passes it along. The […]

Can this PHP function be improved?

Below is some code I am working on for a navigation menu, if you are on a certain page, it will add a “current” css class to the proper tab. I am curious if there is a better way to do this in PHP because it really seems like a lot of code to do […]