Skip to content
Advertisement

Javascript to remove spaces from a textbox value

I’ve searched around for this a lot and can’t find a specific example of what I’m trying to do. Basically I want to get the value of a textbox, by the name of the text box (not id). Then I want to remove ALL spaces, not just leading or trailing, but spaces in the text too. For example for this

Remove all child elements of a DOM node in JavaScript

How would I go about removing all of the child elements of a DOM node in JavaScript? Say I have the following (ugly) HTML: And I grab the node I want like so: How could I remove the children of foo so that just <p id=”foo”></p> is left? Could I just do: or should I be using some combination of

JavaScript file not updating no matter what I do

I have an external JavaScript file and whether in FireFox or Chrome, whether all browsing data is cleared, it will NOT update no matter what. I believe something happened when I made a backup of my file, which I simply added “_thedate” to the end of the name. Then Save As back to the original name. Now I cannot seem

How do I shuffle the characters in a string in JavaScript?

In particular, I want to make sure to avoid the mistake made in Microsoft’s Browser Choice shuffle code. That is, I want to make sure that each letter has an equal probability of ending up in each possible position. e.g. Given “ABCDEFG”, return something like “GEFBDCA”. Answer I modified an example from the Fisher-Yates Shuffle entry on Wikipedia to shuffle

Can setTimeout ever return 0 as the id?

I am writing a check to see if a timeout is active. I was thinking of doing this: I was wondering if it would ever be possible that a will be 0. In that case I would use a !== null Answer First: 0 isn’t the same as null, (0 == null) would be false in every case’; if you

Load google maps v3 dynamically with ajax

When i try to load google maps v3 with ajax the result is: in the source code, i suppose that writes with javascript document.write(); how i can do this without iframe? thanks. Answer This is not supported. Please load the API using supported methods: http://code.google.com/apis/maps/documentation/javascript/tutorial.html#Loading_the_Maps_API

Download data URL file

I’m playing with the idea of making a completely JavaScript-based zip/unzip utility that anyone can access from a browser. They can just drag their zip directly into the browser and it’ll let them download all the files within. They can also create new zip files by dragging individual files in. I know it’d be better to do it serverside, but

Checking if a URL is broken in Javascript

This question has been posted on Stack before, but none so specific as to what I’m trying to understand. The simplest way to check if a URL is corrrect to send a http Head request. But how do you use that to specify the URL ? I found this in a previous post : But it doesn’t seem to run

Difference between console.log and sys.puts in node.js?

In node.js you can use console.log or sys.puts to print out to the screen. What is the preferred method and what is the difference between these? Answer sys.puts simply prints the given string in the logs. But if you want to print a more complex object (Array, JSON, JSObject) you have to use console.log because you want to “look inside”

Is it possible to connect to SSH using JavaScript?

I know there is an implementation of VNC using WebSockets (http://novnc.com) but that still requires a server. I am looking to create a simple client-side JavaScript only (no Flash) connection to a port running SSH. I am guessing WebSockets is the only way to go since it does TCP. Any example code? Any other way? Answer Sorry, given your constraints

Advertisement