javascript

Streamlining my javascript with a function

i have a series of select lists, that i am using to populate text boxes with ids. so you click a select option and another text box is filled with its id. with just one select/id pair this works fine, but i have multiples, and the only thing that changes is the id of the select and input.. in fact just the ending changes, the inputs all...

Using window.open() or a hyperlink with a _target attribute, is it possible to force a link to open in a new window rather than a new tab?

Or is that strictly dependent on the web browser's settings? ...

Is this a good way to identify the type of a javascript object?

Apparently neither instanceof nor typeof deliver in terms of correctly identifying the type of every javascript object. I have come up with this function and I'm looking for some feedback: function getType() { var input = arguments[0] ; var types = ["String","Array","Object","Function","HTML"] ; //!! of the top of ...

Form validation in JAvascript with Regexp

I have a webpage with an input field where only digits are allowed. The input field has an onkeyup event that starts this validating function: function validate() { var uah_amount = document.getElementById("UAH").value; var allowed = /^\d+$/; document.getElementById("error").innerHTML = document.getElementById("UAH").value; ...

Using document.write in event handler?

I am experimenting with HTML and JavaScript. The following code should print something when entering a keystroke in a textbox: <html> <body> <input type="text" id="commandInput" name="command" size="50" /> <script type="text/javascript"> var commandInput = document.getElementById("commandInput"); ...

jQuery works on local host, but not on website

Using Notepad++ and XAMPP to test stuff, then I upload it to the website over FTP. In the head of my code, I have this to call jQuery and the script: <script type="text/javascript" src="/jquery.js"></script> <script type="text/javascript" src="/portfolio.js"></script> and it works fine locally on my XAMPP server. But as soon as it's...

Opening a window in javascript (window.open) on rollover without getting blocked by popup blockers

I like to open a new window (not in the same window) in JavaScript with window.open on rollover (without click event) and it gets blocked by popup blocker in IE and Firefox. Is there a workaround for this? ...

Access inner function variables in Javascript

In many frameworks, internal function variables are used as private variables, for example Raphael = (function(){ var _private = function(a,b) {return a+b;}; var _public = function(a) {return _private(a,a);} var object = {mult2:_public}; return object; })(); here, we cannot access from the global namespace the variable...

Does anyone use config files for javascript?

We have javascript files that are environment specific, and so I was thinking of going down the path of creating a generic way to read in an XML (config) file to store different environment specific settings. I was curious to know if anybody else on here does that (or if not, is there a reason why you don't)? ...

right click values for Gridview column

I have grid named 'GridView1' and displaying columns like this <asp:GridView ID="GridView1" OnRowCommand="ScheduleGridView_RowCommand" runat="server" AutoGenerateColumns="False" Height="60px" Style="text-align: center" Width="869px" EnableViewState="False"...

JQuery tools overlay opens at the top of page instead of overlaying in IE, works fine in FF/Chrome

Here is the sandbox version of my site: http://truxmapper.appspot.com/ To reproduce the error, hover over to the toolbar and go to Support --> FAQ. In Chrome/FF, this will work as expected. In IE, the background image will quickly move to the center of the page, but when its time to insert the div over the background image, its inser...

Cascading Dropdown List

I am working on a web app and trying to code a form with two dropdown lists. The list in the second dropdown will be dependent on the selection from the first one. The task itself isn’t too complicated except that once the first selection is made, I need to make a database call to pull the data for the second dropdown. This is where I...

jQuery append div to a specific

Hi How do I append a element a specific index of the children elements using jQuery append e.g. if I have: <div class=".container"> <div class="item"><div> <div class="item"><div> <div class="item"><div> <div class="item"><div> </div> and I want to append another item between the second and third item? ...

Javascript not executed when iframe added to document?

It seems that adding an iframe to my html document prevents Javascript from being executed. In the following code sample the alert will not be shown: <html> <body> <iframe src="http://www.google.com" /> <script type="text/javascript"> alert("test"); </script> </body> </html> What...

Not allow more than 5 digits after decimal. in on javascript "OnKeyUp"?

I have a javascript code for textbox that will put commas on in digits like (11,23,233) mTextbox.Attributes.Add("OnKeyUp", "javascript:this.value=Comma(this.value);") function Comma(Num) { Num += ''; Num = Num.replace(',', ''); Num = Num.replace(',', ''); Num = Num.replace(',', ''); Num = Num.replace(',', '');...

textarea doesnt return value

Im using a code editor codepress in all of my textareas, but no textarea return a value. I think the different name and id is the problem. Example: <textarea name="content_text" rows="20" cols="50" class="codepress sql" id="myCpWindow"></textarea> I have read somewhere in here to use a hidden input to transfer the textarea's value, bu...

Is it possible to access JSON properties with relative syntax when using JSON defined functions?

// JavaScript JSON var myCode = { message : "Hello World", helloWorld : function() { alert(this.message); } }; myCode.helloWorld(); The above JavaScript code will alert 'undefined'. To make it work for real the code would need to look like the following... (note the literal path to myCode.message) // JavaScript JS...

I need to rotate (scroll) images using the galleria module

I am using galleria & jCarousel and need to have the slideshow scroll through the images. Does anyone know a simple javascript that I can use for that? ...

loading js files and other dependent js files asynchronously

I'm looking for a clean way to asynchronously load the following types of javascript files: a "core" js file (hmm, let's just call it, oh i don't know, "jquery!" haha), x number of js files that are dependent on the "core" js file being loaded, and y number of other unrelated js files. I have a couple ideas of how to go about it, but not...

keypress event not being triggered only at start and end of text field in Firefox (JQuery)

I'm listening for keypress events on an input field with delegation. For some reason, Firefox doesn't trigger the delegated event for cursor UP when at the start of the field, or cursor DOWN when at the end. LEFT and RIGHT work as expected all the time. Directly binding an event listener to the field works fine, so it has to be somethin...