javascript

How do I get the name of a form in Javascript?

How do I get the name of a form in Javascript? I have tried stuff like: document.forms[0].name document.forms[0].id //I have both name and id set ...

Adding floats with javascript

I'm using jQuery, and I want to sum up the values in my table column, everything seems to work fine, but my value is returned a string with all the values added like: 123.5013.0012.35 How can I sum these properly? var totals $(".add").each(function(i) { totals += parseFloat($(this).text()).toFixed(2); }); console.log(totals); ...

help with jquery update content in html

i use jquery ajax to get data from php file. data = <option>Peter</option><option>Maria</option> i want to then use jquery to put this data after the first option <select> <option>Name</option> </select> i cant use html() on select because then the first option will be deleted. what jquery function can i use to put them after th...

local copy of document.getElementsByTagName

Why doesn't the following code work? var f = document.getElementsByTagName; var x = f('div'); I get "TypeError: Illegal invocation" in Chrome, "TypeError: Type error" in Safari. I don't get an error in Firefox, but it doesn't work. I haven't bothered testing in IE or Opera yet. ...

Using JavaScript to Modify a Page on the Fly based on <select> contents

So, I've got a form and within that form is a <select>. Based on what that select is(what <option> is selected), I want the contents of the form to change on the fly(i.e. before the user clicks anything else). For example, if the user selects the Photo Upload option, a file upload box will appear, and if they select Text Entry, a text b...

How to detect/track postback in javascript?

How to detect/track/check postback in javascript(e.g in asp.net Page.isPostBack())? Any suggestion? ...

asp.net Dropdown menu does not show all the texts In IE,when the text is too long the rest get cut off

asp.net Dropdown menu does not show all the texts In IE,when the text is too long the rest get cut off,anyone can suggest any fixes for it.It works ok in firefox. ...

Java script to retrive value from grid

protected void GridLedger_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("onMouseDown", "var str = document.getElementById('" + e.Row.ClientID + "').cells[0].innerText; document.getElementById('<%=TextBox1.ClientID%>').value = str;"); } }...

Set the Dropdown box as selected in Javascript

I am using Javascript in my app. In my table, I have a column named industry which contains value like id 69 name :aruna username :aruna email :[email protected] password: bd09935e199eab3d48b306d181b4e3d1:i0ODTgVXbWyP1iFOV type : 3 industry: | Insurance | Analytics | EIS and Process Engineering actually this industry va...

java script on event handler and color contrasts

The radio buttons when selected work fine in terms of outputting a selected color via the radio buttons onto the page or screen. Each radio button represents a different color. I was wondering if it's possible with some java script to be able to manipulate the contrast of each selected color. For example by constantly clicking the Col...

Path to included Javascript page

How do I get the absolute or site-relative path for an included javascript file. I know this can be done in PHP, (__file__, I think). Even for an included page, one can check the path (to the included file). Is there any way to have this self awareness in Javascript? I know I can can get the page URL, but need to get the JS URL. Eg. ...

How to control usercontrol from javascript

I have an usercontrol with an attribute targetUrl. I add this user control to a page and write targetUrl attribute from this page like below: <PBG:Modal ID="Modal1" runat="server" Height="180" Width="500" src="pop_adres_giris.aspx"/> This worked properly, but I want to change the targetUrl a...

How to call a method in class from its replaced implementation?

Hai, I am trying to understand few concepts in JavaScript. Consider the following code: function Person(name, age) { this.name = name || "no name"; this.age = age || "age not specified"; this.printStr = function() { console.log("< " + this.name + ", " + this.age + " >"); }; } p = new Person("pranav", 26); p...

jquery executes declared function without me clicking

i wonder why the browser displays "logged in" without me having clicked on the link i id-tagged with clickhere. it displays it everytime i refreshes the page. <script type="text/javascript"> $(document).ready(function(){ function login(){ alert("logged in"); } $("#clickhere").click(login()); }); </script> i ju...

javascript scope issue

Code snippet as follows: $(this).parents('td:first').next().find('option').customizeMenu('myMenu2'); This works,but : var listener = function(){ $(this).parents('td:first').next().find('option').customizeMenu('myMenu2'); }; listener(); is not working,why and how to fix it? ...

How do I show a loading image before actual body load?

I want to hide the body of my web page. Once the all content of the body tag of the web page are ready to display I want to show it body, but until that time I want to show some loading image. If for some reason the content of the body does not load properly I want to show an error message. What is the best way of doing this in javasc...

XMLHttp long polling and avast blocking

I am experimenting with long polling XMLHttp Requests (XHR) on this page. Having Avast antivirus installed I noticed that its web shield effectively blocks the use of readyStates<4. Adding an exception for text/xml mime types in the web shield configuration solves this. But is there a way to solve this programmatically? I searched the n...

jQuery check if onClick exists on element

I found the way to check if event exists on element. But it's not work on the events which is not delegated by jQuery... When I try, $("a").data("events"); for this. <a href="#" onClick="alert('Hello, World!')" /> It returned undefined. Is there any way to check if onClick exists on elements with jQuery? Thanks. ...

jQuery - If none of 3 id's have content hide this

Hi All, I have 3 div's drawing content from fields in a database: <div id="one">{data_one}</div> <div id="two">{data_two}</div> <div id="three">{data_three}</div> If none of these three div's have data, can I add some jQuery to hide another div? Thanks, Jack ...

How to force Sequential Javascript Execution?

Ive searched a lot of places for the answer to this seemingly simple problem, but Ive only found rather complicated answers involving classes, event handlers and callbacks (which seem to me to be a somewhat sledgehammer approach). I think callbacks may be useful but I cant seem to apply these in the simplest context. See this example: <...