javascript

Double click event for List box

Can a list box have double click event on its items? ...

Pass anonymous function by value in javascript?

I have a function that accepts an anonymous function as an argument and sets it to a variable (scoped) for reference. I then try to execute another function with that reference but it obviously fails since that function is out of scope. I was wondering if anyone knew of a simple way of passing the anonymous function straight through as...

Parse through xml string using JS

I have an xml string sVal.responseText gives me < NewDataSet > < Table > <FieldID>21</FieldID> <TableName>F003v001</TableName> <FieldName>Grade</FieldName> <DisplayField>Grade</DisplayField> <FieldType>text</FieldType> < /Table > </NewDataSet> i am calling FillTable(sVal.responseXML.documentElemen...

How dangerous is it send HTML in AJAX as opposed to sending JSON and building the HTML?

It seems to me that any interception of this could provide instant trouble because anyone could just send any HTML/script back to the client. The only reason I'm interested in doing this is because of the huge pain it is for front-end developers every time there's a DOM structure/CSS change so you now have to go figure out where in the ...

Random banner only displaying the first image.

I have an external javascript that contains: function random_imglink(){ var myimages=new Array() myimages[1]="http://sevir.sitegoz.com/jchs/Banner1.png" myimages[2]="http://sevir.sitegoz.com/jchs/banner2.png" myimages[3]="http://sevir.sitegoz.com/jchs/banner3.png" myimages[4]="http://sevir.sitegoz.com/jchs/banner4.png" myimages[5]="...

Possible to add large amount of DOM nodes without browser choking?

I have a webpage on my site that displays a table, reloads the XML source data every 10 seconds (with an XmlHttpRequest), and then updates the table to show the user any additions or removals of the data. To do this, the JavaScript function first clears out all elements from the table and then adds a new row for each unit of data. Recen...

Freezing the DOM to JavaScript: Overwriting DOM modification functions as no-ops

I'm writing a piece of code that requires the DOM of a website to remain frozen while arbitrary JavaScript runs. Attributes changing is fine but I can't have anything changing the original tag structure of the page! I know in JavaScript there are a base number of functions that can modify the DOM: appendChild( nodeToAppend ) cloneNode(...

Javascript: How to access a class attribute from a function within one of the class's functions

Within my a certain function of a class, I need to use setInterval to break up the execution of the code. However, within the setInterval function, "this" no longer refers to the class "myObject." How can I access the variable "name" from within the setInterval function? function myObject() { this.name = "the name"; } myObject.pr...

why is the iframe contents empty?

Hi All. I'm trying to understand this bit of code: in display.php: <html> ... <body> <table> <tr> <td> User info: <iframe id="SpControlFrame1" name="SpControlFrame1" src="javascript:'';"path_src="index.php?cmd=YYY" ></iframe> </td> </tr> </table> </body> </html> in another file, I have a sw...

Change the Text of an asp:CheckBox when clicked

How can I change the Text for a CheckBox without a postback? <asp:CheckBox ID="CheckBox1" runat="server" Text="Open" /> I would like to toggle the Text to read "Open" or "Closed" when the CheckBox is clicked on the client. ...

How to use nested Functions in Objects

Suppose you use the following structure: var Args = new Object(); Args.Age = '10'; Args.Weight = '10'; Args.GetAge = function() { return 'I am ' + Age + ' years old'; } Args.GetWeight = function() { return 'I weigh ' + Weight + ' pounds'; } That works great. But is it possible to use a generic so you don't have to create a ...

Ok to use Google Code to host javascript apps for end users?

I am working on a javascript app that users load via a configurable script tag. I have it hosted on its own Google Code project since its open source. Is it ok to have the url that loads the app pointed at the file download link on its Code site? For example: <script type="text/javascript" src="http://myprojectname.googlecode.com/files/...

Setting a multi-valued parameter in javascript

Hi, When I submit a form in HTML, I can pass a parameter multiple times, e.g. <input type="hidden" name="id" value="2"> <input type="hidden" name="id" value="4"> Then in struts I can have a bean with property String[] id, and it'll populate the array correctly. My question is, how can I do that in Javascript? When I have an array, a...

Is it possible to use JS to open an HTML select to show it's option list?

Is it possible to use JavaScript to open an HTML select to show it's option list? ...

G-mail style form submission on table data

I have table rows of data in html being filled from a CGI application. I want each row to have a check box next to it so I can delete multiple rows, just like in gmail. I figured out the basic text form and was able to send it to the CGI program to delete the row, but I don't want to have to type in the row name to delete a single fil...

What does the browser do when the source of iframe is javascript

hi All. When the source of an iframe is: javascript:''; as in: <iframe id="SpControlFrame1" name="SpControlFrame1" src="javascript:'';" path_src="index.php?cmd=YYY" ></iframe> What is going on? What does the src="javascript:'';" tell the browser to do? what does the "path_src" do? Thanks Chris ...

Registered alert script called on BrowserBack

I have a small class that displays an alert via Javascript. I am using this class on a page that checks if the user entered a valid zip code. If a valid zip code is not entered, an alert is displayed, and the page is posted back to the same page so they can change it. If they enter a valid zip code, they are redirected to another page. T...

Performance benchmark: PHP Generated content VS. javascrpt and DOM over AJAX

Hi, For the following pretty straightforward task: query a list of products from a DB and present it on a webpage, consider 2 setups: Setup1: PHP script queries. All content is built on the server and the entire page is served back to the client. Setup2: Static HTML "page skeleton" requesting content using AJAX. Received content is pa...

What is the best way to tell users of my library functions that passed variables are not of the correct type.

I'm currently in the creation of a javascript function library. Mainly for my own use, but you can never be sure if someone else ends up using it in their projects, I'm atleast creating it as if that could happen. Most methods only work if the variables that are passed are of the correct datatype. Now my question is: What is the best way...

How to translate strings in JS

I have a project which I want to translate into multiple languages for the PHP Part I use Zend Frameworks Zend_Translate with GetText. Now I want to translate the JS part too. I am using the jQuery JS Framework and would love to hear your thoughts on translation for JS files ...