javascript

innerHTML within another tag

Hi all, I have a link: <a id="nextBut" href="somelink" class="button"><span>Next Step</span></a> And I can control the the <span>Next step</span> part with innerHTML but how could I leave the <span> alone and just change the 'Next step' part? For example: var NextButJar = document.getElementById('nextBut'); NextButJar.disabled = tr...

JavaScript, jQuery, XML - if statement not executing for unknown reason

Hi, I have a 'for' loop which extracts data from an XML document and adds it into some JavaScript objects, each time the loop executes I want it to run a certain function depending on the value of the attribute 'typ' which is being retrieved from the xml. Currently, the data from the XML is successfully being parsed, which is proven by...

Why does Javascript's OR return a value other than true/false?

I saw this construction in order to get the browser viewport width: function () { return window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; } I understand the browser quirks involved. What I don't understand is why || returns the value. So I tried this alert(undefined || 0 || 3); and sure enough, i...

Javascript RegExp and boundaries

Hi Guys, A colleague asked me about a Regular expression problem, and I can't seem to find and answer for him. We're using boundaries to highlight certain lengths of text in a text editor, but here's some sample code that shows the problem: <script type="text/javascript"> var str = "Alpha , Beta, Gamma Delta Epsilon, AAlphaa, Beta Alp...

Postback of delimited text from javascript and parsing on server side

In my ASP.NET page, I have a Javascript object, like this: var args = new Object(); args.Data1 = document.getElementById("Data1").value; args.Data2 = document.getElementById("Data2").value; args.Data3 = document.getElementById("Data3").value; The object is populated on client side using user input data. I am passing th...

Reload jquery autocomplete in the on change event of a drop down

I have country,state dropdowns and a city textbox with autocomplete feature.My issue is,when I change state, it is displaying previously selected cities since city autocomplete takes data from cache instead of calling server with new stateid.City autocomlete request server response with new stateid only if the cities are not in the selec...

Closing any open info windows in google maps api v3

As the title states, on a given event (for me this happens to be upon opening a new google.maps.InfoWindow I want to be able to close any other currently open info windows. Right now, I can open many at a time..but I want only 1 open at a time. I am creating the info windows dynamically (i.e. I don't know ahead of time how many will be...

Unsure how to design JavaScript / jQuery functionality which uses XML to create HTML objects

Hi, I'm using JavScript and jQuery to read an XML document and subsequently use the information from the XML to create HTML objects. The main 'C' nodes in the XML document all have a type attribute, and depending on the type I want to run a function which will create a new html object using the other attributes assigned to that particu...

How to get a webpage as plain text without any html using javascript?

i am trying to find a way using javascript or jquery to write a function which remove all the html tags from a page and just give me the plain text of this page. How this can be done? any ideas? ...

How to convert a string with escaped characters into a "normal" string

Let's say that I have like this: "\\n", I need to convert it to a string like if the interpreter would do it: \n. A simple replace like this wouldn't work: function aaa(s){ return s.replace(/\\n/gm,'\n').replace(/\\\\/gm,'\\'); } I need this behaviour: "Line 1\nLine 2" => Line 1<Line break>Line 2 "Line 1\\nLine 1" => Line 1\n...

[JavaScript] How to get the uri of the .js file itself.

Hi, is there a method in JavaScript by which I can find out the path/uri of the executing script. For example: index.html includes a JavaScript file stuff.js and since stuff.js file depends on ./commons.js, it wants to include it too in the page. Problem is that stuff.js only knows the relative path of ./commons.js from itself and has...

Dynamically add data to a javascript map

Is there a way I can dynamically add data to a map in javascript. A map.put(key,value)? I am using the yui libraries for javascript, but didnt see anything there to support this. Thanks! ...

Javascript form validation events

Hi All, I am making a small form for a php app and had a question regarding javascript validation. What is the best event to run the javascript validation on the input value? Is it the "focusout" event? I used "focusout" to originally but it creates problems when the user hits enter while they are still focused on any particular fiel...

How do you override an existing html form to use jquery to post the form?

I have a simple form that I am currently posting back to the server to update a nickname. What jquery code do I add (without changing the form) so that the page will not refresh, but instead jquery will post the form in the background and then pop up an alert message containing the reply back from the server? <form method="post" actio...

MS Dynamics CRM 4.0 - onChange event error

Hi I have an onChange event that keeps bringing up the error below whenever I preview it. 'Object doesnt support this property or method' I have the onChange event associated with a picklist and when a specific option is selected another field is unhidden. The code is below: onLoad: //If How did you hear about us is set to event sh...

need to run php script when form is submitted

I have a form that needs to run a php script once the submit button is clicked, it needs to be ajax. <form method="post" action="index.php" id="entryform" name="entryform"> <input type="submit" name="submit" value="Submit" onclick="JavaScript:xmlhttpPost('/web/ee_web/include/email-notification.php', 'entryform')" /> </form> In this si...

jQuery plugin for Event Driven Architecture?

Are there any Event Driven Architecture jQuery plugins? Step 1: Subscribing The subscribers subscribe to the event handler in the middle, and pass in a callback method, as well as the name of the event they are listening for... i.e. The two green subscribers will be listening for p0 events. And the blue subscriber will be listening ...

I need a 2D bone engine for JavaScript

Hello. I'm looking for a way to define a Bone animation system, I need a basic one, since my objective is to apply it for inverse kinematics, much like Flash supports. The desirable feature is that: I can set bones (as position in 2D, defined by 2 dots) each having an ID. So I can make an animation based on frames, ie: ['l_leg', [10...

How to determine loading status of images not attached to the DOM

I am working on a bit of javascript to plot data on a <canvas>. The data points are marked by one of several different (small) image files. I am attempting to have the plot method wait until all the images are loaded. My best attempt thus far is such: var icon = { left : { air : new Image(), bone : new Image(), ...

Dojo fetch, how to wait on two simultaneous async fetches?

Hey guys, im not well versed in dealing with asynchronous design patterns, and im having a problem writing a script that does two async data fetches. Im using Dojo.data.api.Read.Fetch() to make two fetch() calls from seperate databases. The reulsts come back asynchronously. However, I have to cross reference the results, so i want my s...