javascript

Advice needed on JavaScript control libraries

I'm looking for advice/opinions on Javascript control libraries like ext-js, dhtmlx, jquery-UI etc... I've got some background in asp.net and have found the various 3rd party controls to really boost development time. I'm doing a project in PHP and have considered some PHP specific controls, however I suspect I would be better served l...

Why does the Chrome spacing work in one JS file and not the other?

Update: Bug Resolved. Answer points go to whoever explains why the fix works. If you highlight and copy the text in the first paragraph on this page, then paste it into a rich text editor (dreamweaver or gmail in rich text mode), you will see that some of the text is automagically linked. Basically, it works: http://seox.org/link-build...

Javascript: wait until ajax request finishes to close page

I would like the browser to keep the page open until the ajax requests are sent. This is what I imagine it would look like var requestsPending = 0; window.onbeforeunload = function() { showPleaseWaitMessage(); while(requestsPending > 0); } // called before making ajax request, atomic somehow function ajaxStarted() { reques...

remove text from a function (i think)

I am trying to remove the "_" in the "change_option". I managed to add the class ok but that's it <select onchange="change_option('SELECT___100E___7',this.options[this.selectedIndex].value)" name="SELECT___100E___7" class="link_fix3"> Here is the code I have so far... $("form select[onchange^='change_option']") .addClass('link_fi...

Mouse coordinates and rotation

How would you go about mapping mouse coordinates to world coordinates in a 2d context? For example, you have an image which you can drag. Next, you apply a rotation to that image and redraw it. Now when you drag the image it does not get translated correctly. For example after rotating 90 degrees, dragging up would cause the image to t...

jquery event function call with oop?

var objs = new Array(); function Foo(a) { this.a = a $("#test").append($("<button></button>").html("click").click(this.bar)); } Foo.prototype.bar = function () { alert(this.a); } $(document).ready(function () { for (var i = 0; i < 5; i++) { objs.push(new Foo(i)); } }); is it possible to make it so that ...

control radio button from textfield value

hi..everyone..i want after i type "0203-ED" in textfield ...two character behind that text can control the radio button.. "ED" character from that text can make one radiobutton which has value="ED" are checked... this is my code: <script type="text/javascript"> var model=$("#tags1").val(); var version[0,0]="JD"; var v...

Getting XML Element by name in ajax responseXML?

I'm having an issue with an AJAX script I'm fixing - an AJAX connection is being made, XML data is returned (Properly), however the data is not being shown correctly in any browser other than IE. Elements are being gotten by using xmlData.childNodes[1] - which works fine in IE, but in Opera, Firefox, Chrome, etc., different data is retur...

How to handle browsers where JavaScript may be turned off?

Suppose I'm developing a web app that is heavily dependent on JavaScript and which uses AJAX for all the POST commands to store data, etc. How should one deal with those situations where a user may have JavaScript turned off? Is it unreasonable to require that a user's browser has it turned on? Are there any best practices for these...

How to update/append a string with javascript?

I want to check whether in querystring there is something like [?|&]rid=\d, if there is,I want to update the \d with a specific rid_value, else I want to append &rid=rid_value to querystring ...

jQuery - Can't seem to .live() bind to a label element. Why?

Here's my code: HTML: <ul id="more-items"> <li><label class="button">hi</label></li> <li><label class="button">hi</label></li> <li><label class="button">hi</label></li> </ul> Javascript: $('ul#more-items label.button').live('click', function() { alert(1); }); Clicking on the labels doesn't cause the alert() to fire. Th...

jQuery: How do I pass a value into an Ajax call?

I am updating some div as follows: for(var i = 0; i < data.length; i++) { var query = base_url + data[i]; $.ajax({ url: query, type: 'GET', dataType: 'jsonp', timeout: 2000, error: function() { self.html("Network Error"); }, success: function(json) { $("#li" + i).html("...

Is there something like PHP's preg_replace_callback() in javascript?

What I want to do is str.replace(pattern, callback), not simply str.replace(pattern, replace_pattern), is it possible to do it in javascript? ...

Need to access same boolean result in all layers of web dev abstraction

I am designing a web site, and it has the ability to log in. When someone is logged in, there is at times a need to know what group they're in. Specifically, whether they are in the officer group. Currently, I have a MySQL stored proc BOOL is_officer(INT id), where id is the user id number. My question: Is it wise to make a PHP function...

AJAX post to simulate Input type="file" path

Hi, I would like to know if its possible to make an AJAX post request to submit a file path to a form. Basically, I want to know if its possible to simulate the path a normal input type="file" would create, but in an AJAX request. Also, is it possible for that link to be pointing to a file on another website? I think I have no other cho...

Detecting whether user is logged in or not from a Chrome extension

Hi, is there an easy way to detect from a Chrome extension that the user is logged into his google account or not. I guess there is a nasty way to figure this out by loading a html/css/js resource that requires authentication. But i'd like to do this in a "clear" way. thx and best, Viktor ...

Find out sandbox.open(url,null.....) execution time

I am using Jaxer.Sandbox.open(url,null,openOptions); method to fetch url contents. I want to find out time required to fetch url content. If this process took long time say more than 6 sec. then custom error page should display. ...

.change(function) can control two command

dear all..i've a textfield, it using barcode scanner for input data..after scan it shows KD-R411ED 105X0001... I'm successful separate them into two text field use ".change(function)" $("#tags1").change(function() { var barcode; barCode=$("#tags1").val(); var data=barCode.split(" "); $("#tags1").val(data[0]); $("#tags2").val(d...

What kind of Ruby / Erb is allowed inside HAML's :javascript filter?

It seems that inside of HAML's :javascript filter, no Ruby code is allowed, not even a comment. So this is NOT allowed: :javascript - 1.upto(10) do |i| :javascript -# just a comment not to show to public (somebody said there is not way to hide comment like that inside a :javascript filter. Is that true? but it seems the only t...

How to do it more efficiently?

Let's imagine we should get some data... var data = []; //some code omitted that might fill in the data (though might not) Then we need to do something with the data. And my question is how to do it more effectively. Like so?: if (data.length) { for (var i = 0; i < data.length; i++) { //iterate over the data and do somet...