javascript

How can I get the text of the selected item from a dropdown using jQuery?

I need the text from the selected item in a drop down. Thanks in advance! ...

addClass/removeClass to a SubClass?

Hi Guys, I am new to javascript and still learning the ropes. I am trying to use addClass to a subclass I assumed that this would work: jQuery('#wrow .text').addClass("error"); jQuery('#wrow .text').removeClass("error"); But it doesn't ? Little unsure how to do this to subclasses ? I am sure you gurus will help in a jiffy! :) Edi...

ASP.Net - How do I include an embedded JavaScript file from another project?

I've got two projects, one is a control library and another is my main project. From the control library I am currently using a user control and some css files which are embedded in the control library. I can use the embedded CSS files in my main project by doing the following from my user control's PreRender event: // Register the d...

JQuery Problem: Script (Sometimes) Fails On (Some Versions Of) IE7

I'm using an image cross-fading method via jQuery on a website. For confidentiality reasons, I can't post the site's entire code, but here's the Javascript for the cross-fader (based on this reference): <script type="text/javascript"> $(function () { if ($.browser.msie && $.browser.version < 7) return; ...

How to detect that user open page using BACK button in browser?

Idea is to display message, which will infor muser that ajax part of application can wokr incorrectly when he used "back" button. Yes, there is a lot of discussions, but no solutions. Best from what I found: Store information about last page on server side, and check current page against server info by ajax. But in this way it would be ...

Should I be using JSON or XML or something to fetch a pages contents every X amount of time?

index.php has this jquery code which loads notifications.inc.php into a div on the page every X amount of seconds <script type='text/javascript'> $(document).ready(function(){ var updatenotification = function(){ $('#notificationcontainer') .load('notifications.inc.php') .fadeIn("slow"...

Javascript: Possible Access To Modified Closure Issue... How To Beat?

For some reason no matter what, the pageNumber ends up being the last value in the loop for the loopCounter. Now I would understand that if I were directly using loopCounter in the closure itself, but I'm not. As you can see from the code below, I am creating a new variable within the closure to take the current value of loopCounter. ...

How to access remote JSON data as a local array

I'm able to use Jquery's $.get function to access JSON data from another URL, but how can I use that data (as an array) elsewhere in my code? Consider the following code: <script type="text/javascript"> $(function () { $.get("/some/other/url/that/returns/json", function(data){ var d = eval(data); }); ...

upload and proces user selected file in html, javascript and php

I want to have a user select a file and then have php put the contents in db. Now the last part (processing the file in php) is easy. But is there a way I can process a user selected file whithout a new page load? If I use the following: <FORM ACTION="upload.php" METHOD="post" ENCTYPE="multipart/form-data"> <INPUT TYPE="file" NAME="som...

Prototype's DOM extensions are colliding with a 3rd party JS library -- what's my best bet?

I just spent almost 2 hours debugging a third party JavaScript library only to find that an array which I pass to that library gets converted to a string somewhere down the pipe... I don't know why or how that happens, but as soon as I remove Prototype from my project, everything works fine again. Could that be because of Prototype exte...

To build a `Delete` -button efficiently with JavaScript / PHP

Which of the following code is better in building a delete -action for removing a question? 1 My code <a href='index.php?delete_post=777>delete</a> 2 Stack Overflow's code <a id="delete_post_777>">delete</a> I do not understand completely how Stack Overflow's delete -button works, since it points to no URL. The id apparently can ...

IE not rendering change in element display after changing it with javascript

Situation: I have a check box and a div container inside another div container. When the check box or the label for the check box is clicked, the inner div's display style should change. If the display is set to block, then it should change to none and vice versa. Code: HTML: <input id="oper_sale" type="checkbox" name="oper_sale" onc...

using javascript to manage element Events

I have simple HTML Textbox with couple of events like "onfocus" change backgroud color, "onkeypress" making sure only accepting numerals, "onblur" formatting and validating the numerals to us-phone format, "onmouseover" showing the tooltip, "onmouseout" hiding the tooltip etc. I want to manage all the events dynamically without using ...

IE Hangs on Second Time a Value is Passed to a Parent Window with Javascript

I've got an ASP.NET 3.5 web app where I am trying to return a string from a child window to a parent window. It works in FF, Chrome, and Safari, but IE is a different story. In IE, it works the first time through but when reopening the child and passing another string, the parent page hangs in the middle of the PostBack. For the paren...

LocalConnection between different instances of the same SWF?

Hi, I'm building a simple audio player in AS3. I would like to embed multiple instance of this audio player in my html and when one's playing, others are paused. Is it possible to use LocalConnection to communicate between different instance of the same swf? From what I could test, once the connection is made with one instance, the othe...

How do I hide a parent element using jquery?

Suppose the following HTML: <li class="fooli"> <a class="foo" href="javascript:foo(this);">anchor</a> </li> <li class="fooli"> <a class="foo" href="javascript:foo(this);">anchor</a> </li> and the following Javascript (using jquery 1.3.2): function foo(anchor) { alert($(anchor).attr('href')); } My goal is to be able to hide ...

How can I get the font size of an element as it was set by css

I'm writing a simple jQuery that to change the font size of an element by a certain percentage. The problem I'm having is that when I get the size with jQuery's $('#el').css('font-size') it always returns a pixel value, even when set with em's. When I use Javscript's el.style.font-size property, it won't return a value until one has been...

JSON return format in ASP.NET MVC

Hi! Actually my question is simple. I think. But unfortunately, Google can't help me this time. I want to return a JSON in my view in this format: [[0,"Mark Kordon",null,"My HTML - Mark Kordon"],[1,"John Doe",null,"John Doe Markup"]] How is this possible? Thanks! ...

Emulating SQL LIKE in JavaScript

How can I emulate the SQL keyword LIKE in JavaScript. For those of you who don't know what LIKE is, it's a very simple regex which only supports the wildcards %, which matches 0 or more characters, and _ which matches exactly one character. However, it's not just possible to do something like var match = new RegEx(likeExpr.replace("%",...

Javascript object member reassignment of value.

I need to change a value in a javascript object. var wba_product = { sku:'12ZB7', availability:'Usually ships in 1-2 business days', } I want to change this using javascript. <script language="javascript" type="text/javascript> if(wba_product.sku == '12ZB7') wba_product.availability + ' Items are charged to your credit card ...