javascript

Dynamic object literal in javascript?

Is it possible to creat an object literal on the fly? Like this: var arr = [ 'one', 'two', 'three' ]; var literal = {}; for(var i=0;i<arr.length;i++) { // some literal push method here! /* literal = { one : "", two : "", three : "" } */ } Thus I want the result to be like this: literal =...

I placed one side menu upon one transparent page, if i click on hide option present on that side menu then that transparent page should be hilighted

I want to design one page in html that as follows, i placed one side menu upon one transparent page, if i click on hide option present on that side menu then that transparent page should be highlighted as well as that menu should be hide. Whenever i want that menu to be highlighted again i can click that menu link. Can any one help me re...

please tell me how can i access value of gridview's cell in javascript

i have a gridview witch contain 4 databound columns and 2 templated column. in one of template column i placed a dropdownlist(witch contain number of items). and 2nd column of gridview contains prices. so in last column i want that when i select value in dropdownlist that value should multiply with 2nd column's value of datagrid and plac...

organize HTML inside Javascript functions

Consider a Javascript function to add a HTML element to a page. In that function a line where you specify the HTML of the element is needed. But if this HTML is complex, then it can make your code look ugly and difficult to debug. Consider the following example (play attention to the ul.innerHTML like): function addHTMLField(area,limit)...

JS date converting

Hay, how can i turn a string like "04 Jan 2010" into a string like "1/4/2010". Can i do this with the JS date object? Thanks ...

innerhtml IE problem (Not with appending content but reading)

Hi all, I need to dynamicaly change css, and I'm doing that by looking at <div id="page_title">Homepage</div> -> this element I'm checking its innerHTML if the title is homepage then change style if page name is about change css to this and that etc. Now this works in ff but not in IE7, what is the work arround this? I found some ...

Invoking button click on ASP.net client side programmatically

I'd like to invoke a button click event on an ASP.net page programmatically, using c#. I don't have access to the server-side of the page, so i can't invoke the function directly. Is it possible at all? ...

show/hide image on click

Hi, I need to show/hide image in html page. I thought its very simple. But why I am getting error 'visible' undefined. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" > <html xmlns="http://www.w3.org/1999/xhtml"&gt; <head><title>Ajax Test </title> <script ...

window.print not working in Firefox

function CallPrint() { var prtContent = document.getElementById('<%= pnlDelete.ClientID %>'); var winPrint = window.open('', '', 'left=0,top=0,width=800,height=600,toolbar=0,scrollbars=0,status=0'); winPrint.document.write("<h3>Summary</h3><br />" + prtContent.innerHTML); winPrint.document.close(); ...

Question about functional OOP style in JavaScript

I prefer to use functional OOP style for my code (similar to the module pattern) because it helps me to avoid the "new" keyword and all problems with the scope of "this" keyword in callbacks. But I've run into a few minor issues with it. I would like to use the following code to create a class. namespace.myClass = function(){ var sel...

please tell me where i am doing mistake in following javascript code of conversion to float

i wrote following code to do some of a specifice column of gridview.. but its not working please tell me were i am missing... function ManipulateGrid() { var gvDrv = document.getElementById("<%= GridView1.ClientID %>"); var gt=0.0; for (i=1; i<gvDrv.rows.length; i++) { var cell = gvDrv.rows[...

Connect to SQL Server with JS

I stumbled across a post on here regarding connecting to a DB with JavaScript. http://stackoverflow.com/questions/857670/how-to-connect-to-sql-server-database-from-javascript I'm building a gadget for windows vista/7 that will work with My Movies, a movie management app for Media Centre. The My Movies app uses SQL Server 2005 Express f...

Opening html modal dialog

All, I need to get the contents below on a modal window.I had been trying this for a while today. On modal window opened the background body contents are not accessible.and on reload page the modal popup should close down leavinfg the contents of the text area as it is. <a href="" id="link">Open Popup</a> <table><tr width="10%"><td> ...

How can I run JavaScript code at server side Java code?

I want to run JavaScript code at the server side. I want to manipulate result returned by JavaScript inside my Java code. How can it be done? ...

pass dictionary to controller asp.net mvc

I am wanting to pass a dictionary of type <int,int> to my controller via an Ajax post. The main reason here is the post may have between 1-3 key value pairs here (none of these values are known at compile time) and in the future it may go up to 5. Also in the post I have to pass in some other data, such as Id and name, which all works a...

how to rescrict JS script being inserted in DB with php

Hi all, I have one problem regarding the data insertion in php. In my site there is a message system. so when my inbox loads it gives one javascript alert. I have search a lot in my site and finally i found that some one have send me message with below text. <script> alert(5) </script> So how can i restrict the script code bein...

javascript: remove all object elements of an associative array

Hello All, I would like to know the most efficient way of emptying an associative array without causing any memory leak (the values are js objects) Just to be sure, I have tried iterating through the elements of the array, calling 'delete' operation for each element object, so that all of the element objects will become candidates for ...

javascript, circular references and memory leaks

From what I recall of a not too distant past, Javascript interpreters suffered from memory leaking issues when faced with circular references. Is it still the case in the latest browsers? (e.g. Chrome, FF 3.5 etc) ...

Is it possible to deregister Javascript prototype extension

Hello, I understand that using for..in loop to iterate over Array is not the recommended way for iteration. But I am curious to know if there is a way to deregister these extensions. I have worked with Groovy and in Groovy's case there is a registry which can be manipulated during runtime to erase the additional entries specified throug...

How to reliably submit an HTML form with JavaScript?

Is there a way to submit an HTML form using JavaScript that is guaranteed to work in all situations? I elaborate. The common approach seems to be: formElement.submit() That is all good and well except for one thing. Fields of a form are available as attributes of formElement, so if there is a field with name or id "text1", it can be ...