javascript

switch statement in Jquery and List

Hi, I would like to know if my approach is efficient and correct. my code is not working though, I don't know why. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; <html xmlns="http://www.w3.org/1999/xhtml"&gt; <head> <meta http-equiv="Content-Type" content="te...

Testing Javascript that Manipulates the DOM

I've been looking into javascript test suites and I have found QUnit to be very interesting. I understand how to test computational code, but... How do you test javascript applications written primarily for DOM manipulation? it seems like testing the position/color/etc of DOM elements would be a moot point because you'd end up doing so...

Is there a preexisting Javascript function to read "2009-09-16T11:10:00" as a date?

Possible Duplicate: How can I convert datetime microformat to local time in javascript? Im writing up an ajax application where i have to interpret this date "2009-09-16T11:10:00" and output another string to something more readable. ...

rails and jquery: script displayed instead of execution

Hello there, I'm having a little trouble using jQuery in Rails. I'd like to call the destroy method for a specific list item and then remove it from the list via ajax. My code is pretty simple: # _web_profile.html.erb - The partial containing the link to destroy: <%= link_to 'Remove', web_profile, :method => :delete, :class => 'remove...

Javascript Regular Expression problem

Hi everyone, I am trying to incorporate a regular expression i have used in the past in a different manner into some validtation checking through javascript. The following is my script: var regOrderNo = new RegExp("\d{6}"); var order_no = $("input[name='txtordernumber']").val(); alert(regOrderNo.test(order_no)); Why woul...

Javascript Validation or ASP Validation?

I was talking to a co-worker and we had a discussion on client side validation. Which validation method is better (javascript/asp.net validation)? I know when javascript is disabled on the browser then validation would be disabled but with asp.net validation control, you can just call the method page.validate() to do validation even ...

__DoPostback posts back the values of disabled controls when doing a partial postback

I have a form which, for the sake of isolating the problem, has about a dozen plain HTML checkboxes (not WebControls), all of which are disabled. They are inside an UpdatePanel. I have a link which calls __doPostBack('a-control','my-custom-argument'); Depending on the first argument I supply, the page may do a full postback or a...

Simple AJAX JS works fine locally in Safari, fails on server and in Firefox (issue with evalJSON())?

I wrote a script that polls Twitter via Prototype's AJAX methods, grabs JSON results, evals them and then updates a div with the formatted tweets. Everything worked fine in testing (Safari 4.0.3 on a OS 10.6.1 machine) until I loaded the script onto a server and it failed. The script had all client side items and referred to the same Pro...

Another Javascript Regular Expression problem

Hello again, I have a similar issue as my recent post but with a zip code validator i am trying to convert over to a javascript validation process. my script looks like so: var regPostalCode = new RegExp("\\d{5}(-\d{4})?"); var postal_code = $("input[name='txtzipcode']").val(); if (regPostalCode.test(postal_code) == false)...

RegisterStartupScript and order of execution

I am using ScriptManager.RegisterStartupScript to register calls to a large number of JS functions. ScriptManager.RegisterStartupScript(this, this.GetType(), "Script1", "SomeScript1", true); ScriptManager.RegisterStartupScript(this, this.GetType(), "Script2", "SomeScript1", true); ScriptManager.RegisterStartupScript(this, this.GetType()...

Fade working on FF but not on IE

This is my site: http://noamsm.co.il It should fade-in some text when the search box gets focus. and fade-out on blur. But it isn't working. You can view source; I put the jquery code in the page. ...

Why doesn't my code append to the string within the loop?

I'm using jQuery, building a table through a loop. I thought the best way of doing this would be to create an array then do $(blah).html(table); var settings_table = '<open the table>'; $.each(settings, function(i, val){ var settings_table = settings_table+'<put stuff in it>'; }); var settings_table = settings_table+'<close it...

jQuery Validation Enable Submit Button when Valid

I am using jQuery validation on my form and I would like to be able to disable the submit button and change its class, when the form validates. I know I could bind a function on the key up event but I want to know if this is possible from within the jQuery validate framework. I tried doing what this guy suggested, but got nowhere. I am...

[Javascript + HTML] Dropdown selector, change to target="_blank"

I have a dropdown selector in place and I need to change it so that the target="_blank" so it opens up a new tab. Here is the current code: <SCRIPT TYPE="text/javascript"> <!-- function dropdown(mySel) { var myWin, myVal; myVal = mySel.options[mySel.selectedIndex].value; if(myVal) { if(mySel.form.target)myWin = parent[mySel.form....

Copying from form to form in jQuery

I had a requirement to copy all fields from one form to another similar form. So instead of copying field by field I wrote a routine, form2form, using jQuery. function form2form(aF1, aF2) { var selection = "#" + aF1 + " .copy"; $(selection).each(function() { document.forms[aF2].elements[$(this).attr('name')].value = $(this).val(...

Placing jQuery Refernce at the bottom of HTML Document breaks User Control

Walter Rumsby provided a great answer to Where to place JavaScript in an HTML file. He references the work done by the Yahoo Exceptional Performance team and their recommendation to place scripts at the bottom of the page. Which is a hard and fast rule that I've been following for quite sometime now. In the same thread Levi Rosol pointed...

Javascript timers & Ajax polling/scheduling

Hello, I've been looking for a simpler way than Comet or Long-Polling to push some very basic ajax updates to the browser. In my research, I've seen that people do in fact use Javascript timers to send Ajax calls at set intervals. Is this a bad approach? It almost seems too easy. Also consider that the updates I'll be sending are ...

Converting keystrokes gathered by onkeydown into characters in JavaScript

I try to convert keystrokes into chracters. In other question someone recommand to use the onkeydown function because onkeypress gets handeled differently by different characters. I don't know how to handle special chracters like ´ ` ' ( ) that might be different in different keyboards around the world. ...

JavaScript error while trying to hide table rows

Hello everyone. I am trying to display rows depending upon users choice. Suppose (s)he wants only 3 rows, then the fourth and fifth row will hide. Please find below the part of html and javascript. HTML <table> <tr id="sRow1"> <td>1a</td> <td>1b</td> </tr> <tr id="sRow2"> <td>2a</td> <td>2b</td> </tr> <tr id="...

Round Down Number

How can I round down a number in Javascript? math.round() doesn't work because it rounds it to the nearest decimal. I'm not sure if there is a better way of doing it other than breaking it apart at the decimal point at keeping the first bit. There must be... ...