javascript

How do I auto select an input field when I load a page?

How do some sites automatically select a input field when you enter a page? Like YouTube's login page it selects the Username field automatically This site too, on page Ask Question for example, it selects the Title field. How do they do this? My guess would be javascript But how? ...

Help with disorganized ajax calls + django

I'm having some trouble trying to organize a bunch of ajax calls I have on my index page of a record submission application. This is what I'm trying to do: I have a list on my /index page that hold a list of items I have in a database. This list is generated by django when I send an ajax call to /show_list and then load it into the o...

Difference Between Class Properties and Function Prototype in Javascript

Hi, I like to learn the difference between Class Property and Prototype in Javascript what I mean is shown in the code : function Rectangle(x, y) { this.width = x; this.height = y; } Rectangle.UNIT = new Rectangle(1, 1); Rectangle.prototype.UNIT = new Rectangle(1, 1); The thing I know is prototype is working like inherit ob...

Java += Means What?

In Java what does += do or mean? for example: devtop += Math.pow(x[i] - mean, 2); ...

Dynamically adding more form fields in a table does not resize the height of the row.

On this page, I have a form to enter information about students on a given roster. Each student is listed in a table with a drop down box and a comments field. There is an "add another" button for each student, so that if the user wants to enter a second note about a student, they can. Clicking the button launches this javascript functi...

Load up entire table again or add row manually?

Hi This is an ajax questions. I have a table this table shows users information at certain time depending on what settings the user sets. Now in some cases a user will see the information right away and in some cases they won't it all depends on when they want to see the information. Now what should I do? Should I do? do a post and ...

Get text nested within elements in jQuery

I have this DOM structure: <span id="aa"><a id="bb">myname</a> test test test</span> I want to be able to select #aa and then split #bb away from the text "test test test" since I need to perform some string operations (replace) with the text. How do I select just the text in this case? And then after the string replace operation, I w...

JSON.parse Html content

I am trying to call JSON.parse, where one of the values is html. I have tried running HtmlEncode, to no avail. FF seems to work fine, however IE7 throws an error. Here is an example of my json string that I wish to parse. [{"Title":"Bed","ImageUrl":"~\\/Test\\/sample-product.ashx?w=410","ProductUrl":"\\/products\\/AB10005.aspx","Descr...

Javascript Selected Anchor

I'm not sure if I have seen this right but using the jQuery UI Themeroller the current theme settings seem to be stored in the URL like http://www.site.com/page.html#theme-details... Is there a way to extract the data from this using javascript? So I would return something like theme-details... From the URL I just mentioned Or have ...

Scan through JSON technique

I have this JSON for smilies list var smiliesList = { "sm-1":":)", "sm-2":":(", "sm-3":";)" } There are lots more than 3 actually. In other part of the code I use smiliesList["sm-1"] to get ":)". However, I want to get the opposite now. I have a text string, I want to go through the whole smiliesList and replace ":)" with "sm-1" and...

Is this possible in JavaScript?

I want to create a game similar to ElastoMania in JavaScript. I was wondering, would the collision detection be impossible using divs because they are square, and the game principle revolves around driving up slopes etc? Would this be doable in canvas? Also, would using a library such as jQuery slow down the running of a JS game? I've...

javascript to create process

I want to execute a process named notepad.exe or any exes in javascript and i want to handle the process in javascript by giving input and so on. I think there is a shell command used in javascript to create process can anybody brief me or help me with the example how to work with process in javascript? ...

javascript alert terminates rest of script

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; <html xmlns="http://www.w3.org/1999/xhtml"&gt; <head> <title>Login</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript">alert("Hola amigo")</script> </head> <body> --I ...

I need to show bigger image when image is clicked, is there any good jQuery plugins for this?

I need good and small plugin to show bigger image. One requirement is that images are different images, because images might be large, so if user dosen't click on image, then user doesn't have to download big image, but just smaller image. ...

What are some real world uses for function.toString() in javascript?

I've noticed in javascript that if you define a function, say myfunction(), and then call myfunction.toString() you get the text of the source for that function. Are there any interesting/real world uses of this? ...

HTML Form and Javascript Confirmation

I'm having a problem with submitting a form and Javascript confirmation. Basically, the following Javascript is called when the "submit" button is pressed. function confirmation() { var answer = confirm("Are you sure you wish to edit?") if (answer) { window.location = "#editform2"; } } However, when I hit the canc...

jQuery Problem - How to solve?

I have a jQuery requirement like: I have an Image. If I click it once its size will get reduced. If I again click it it will again resize. Do we have any functionality to do it easily in jQuery? Or do I have to set a flag and then work on mouseclick? Something like $("#img1").click(function() { $("#img1").addClass("img1"); ...

.NET C# - Call a javascript method after the page has validated?

I have a simple javascript (JQuery based) method that does some css magic to show/hide some divs when a user submits a .net web form function doShowHide() { $('.Button').hide(); $('.ButtonHdn').show(); } I'm using the built in .net control validation, so I need the WebForm_DoPostBackWithOptions() method to run in addition to the j...

How to call javascript function with flash/actionscript 3

I want to call my update(id) javascript function from my flash menu with actionscript 3. How do I do? ...

UI Patterns in JavaScript

What UI patterns do you usually use in JavaScript? By UI patterns I mean best practices to be used to build and organize UI, generated/managed from JavaScript (apart from libraries like jQuery or YUI). For example, if you came from .NET world you are familiar with MVC (Model-View-Controller) patterns family. In the world of WinForms a...