javascript

jquery toggle for different browsers

I'm trying to get the following jquery toggle to work on IE, FF, and as many browsers as possible, but currently it works only on FF. Here, I've got the toggle available (between drop-down select and textarea) only when a certain option is selected ("bbb" in this case). Also, is there a better way to write the same script (a cleaner way,...

jquery/javascript How to add image on top of column header

I am implementing a column re-ordering functionality for a grid. When I drag the column, I want to have an arrow in between column headers to give the user a feedback of where the new column would be placed. SOmething that we have in tab re-ordering in firefox. How do I add this image in between and on top of two column headers. Can I cr...

How to .substr() a integer in Javascript

As the title says, which function will give me a result similar to what .substr() does, only for integers? Thanks! UPDATE: Here is what isn't working: if ($(#itemname).val() == "Not Listed") { var randVal = Math.random() * 10238946; var newVal = randVal.toString().substr(0, 4); $("#js_itemid").val(randVal);...

Chrome Developer Console Can't Run JS Loops

In the chrome console, I can't run any loops. Why is this? For example, the following will give a syntax error of "Expected '('" for each (var item in [1, 2, 3]) alert(item) ...

adding external .js using DOM then calling function from the .js

Hey all, I'm trying to build a bookmarklette. I want to minimize the size of the javascript within the bookmarklette so that I can maintain most of the code in an external file. My goal is to... 1) Add an external .js file to the page. 2) Call a function from that external .js file. 3) Have that function add additional .js files to the ...

Can node.js replace Ruby?

Hi, I'd like to know if it's possible to create a complete website using node.js (just like we do using Sinatra and Rails). Also, is there any framework as good as Sinatra and Rails? Is this the best use for node? Regards. ...

You must have JS enabled message?

What's the best way to implement a "you must have JS enabled" message? My site simply won't work without JS at the moment. Should I use the <noscript> tag? Should I hide the entire page's content, put a message about needing JS enabled, and then hide the message and show the content with JS? -- This might cause the message to be tempor...

Robust auto-refresh web page

I have many web pages that needs to auto-refresh once a minute. Easily done with META REFRESH or a some javascript. (And yes, the whole pages needs to refresh -- LOTS of content changing). However, it needs to be as robust as possible. If the web server is momentarily down or there is a network hiccup, it can't refresh and will then ...

Scrolling to an element within a div

I have an absolutely positioned div which acts as a modal window in the center of the page. The modal window is vertically scrollable with a scroll bar on the right hand side. The page itself is also vertically scrollable with a scroll bar on the right. I would like to be able to click on a link and have the modal window scroll to the ...

Changing iframe src with Javascript.

I am trying to change an iframe src when someone clicks a radio button. For some reason my code is not working correctly and I am having trouble figuring out why. Here is what I have: <!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.or...

dynamic html forms

I am working on dynamic form. i have a radio button, if a user select a radio button, i want to populate a drop down menu based on the radio button values. eg. if radio button value=value1 show drop menu of 3 items (apple, banana, mango) eg. if radio button value=value2 show drop menu of 5 items (apple, banana, mango,apricot, ornag...

JavaScript Regex to Java Regex - Replace and Lambdas

What is the best way to approach translating this code into Java? (the section called Convert Alpha-numeric Phone Number to All Numeric) http://lawrence.ecorp.net/inet/samples/regexp-format.php Since Java doesn't have a lambda yet... what is the best approach for the String.replace ? ...

When to use node.js vs sinatra vs rails?

Hi, What are the best uses for these 3 languages/frameworks? Is it useful to mix all of them (or 2)? ...

Get ID from URL with jQuery

I've got a url like this: http://www.site.com/234234234 I need to grab the Id after /, so in this case 234234234 How can i do this easily? ...

Is there a way to make jQuery .js file only contain the functions I use?

Well, I am using jQuery in my project, but I really don't use any effects, only the $.ajax function, is there a way to make jQuery .js file only contain that function or maybe a similar function that doesn't depends on jQuery? I am coding a library, so I don't want to have a jQuery dependence. ...

How can I count the number of referrals from a certain URL

Lets say there's a landing page. I need to be able to count the number of referrals coming from 4 different URLs. So then I can come back later and see how many came from each. Can someone show me how this can be done? Can this be done with javascript using an array and the referrer property or would i have to use PHP thanks so much i...

Javascript: Sort array and return an array of indicies that indicates the position of the sorted elements with respect to the original elements.

Suppose I have a Javascript array, like so: var test = ['b', 'c', 'd', 'a']; I want to sort the array. Obviously, I can just do this to sort the array: test.sort(); //Now test is ['a', 'b', 'c', 'd'] But what I really want is an array of indices that indicates the position of the sorted elements with respect to the original elemen...

javascript confirm asp.net button never submits?

Hi All, i have a regular asp:button. I am working in .Net 3.5. I've tried adding a js confirm to the button with the OnClientClick attribute as well as adding in code-behind and the result is the same. No matter what the user clicks in the confirm pop-up the form will not submit?? BtnDeleteSelected.Attributes.Add("onclick", "return con...

Changing the URL facebook displays for a shared page

How do I keep the URL of the content facebook is sharing the same, but change the URL that facebook displays via the Share button to something of my choosing? ...

Is it possible to disable autocomplete?

I know i shouldnt do it but it may be easier then explaining to the clients that you should do it through the browser. They have a public computer and a server running on the machine in an admin account (the code i am writing). They want people to enter their information but they dont want someone pressing down on the email input box to ...