javascript

Can a JavaScript object have a prototype chain, but also be a function?

function a () { return "foo"; } a.b = function () { return "bar"; } function c () { }; c.prototype = a; var d = new c(); d.b(); // returns "bar" d(); // throws exception, d is not a function Is there some way for d to be a function, and yet still inherit properties from a? ...

How do I display the selected values in an <html:select> when the page loads?

I have a JSP page which contains an HTML <select> populated with all countries loaded from a database. Say for example, on "create user" all the country values are loaded in the select menu and I select 5 countries. Those 5 values are loaded into database for that particular user. Now when I click on "modify user" for that userid again ...

phpcode generating broken javascript and html code

Hello, I have the following PHP code pasted here: http://www.nomorepasting.com/getpaste.php?pasteid=22461 Which produces the following html code: http://www.nomorepasting.com/getpaste.php?pasteid=22462 My problem is that the popup window is not created, or if it is created that it is empty. I have used JSON encode as previously sugg...

hiding text and changing images with css

Hello, I am trying to generate a html page with css that works as an image preview kind of thing. An example of this is here: http://www.nomorepasting.com/getpaste.php?pasteid=22463 however this approach has several drawbacks. One of which is the text must always be smaller than the images. I tried using a different attempt here: htt...

Custom Control not displaying one of the properties when status changes for mouseover

A toolbar control has been created as a common user control, this control has 2 different states (checked and unchecked). When the state changes it is suppose to display a different tooltip based upon it's state. However, I can only get a single tooltip option to display even though the state changes to (checked or unchecked). Case ...

Javascript's setTimeout function not calling

The setTimeout function always seems to give me trouble. Right now I have a function that is recursive (calls itself through setTimeout) and changes the elements height. The function is sent two arguments: the element to be altered and that elements maximum height. The purpose of the function is to unfold the element, or "slide down" at...

ASP.Net Script Controls, Returning False from OnClick, and FireFox

Short Explanation: I have a script control that has the click event being handled in the script file. The Click handler pops up a confirm prompt and returns the prompt's value. Problem: IE sees the return False (Cancel is selected on the confirm box) and there is no postback. Firefox ignores this and fires the postback. Solution...

Event handlers inside a Javascript loop - need a closure?

I'm working with a bit of html and Javascript code that I've taken over from someone else. The page reloads a table of data (via an asynchronous request) every ten seconds, and then re-builds the table using some DOM code. The code in question looks something like this: var blah = xmlres.getElementsByTagName('blah'); for(var i = 0; i < ...

Javascript onchange functioning in a textarea (Symbian browser)

This may apply to other mobile operating environments than just Symbian... However, the issue is that when changing a text area field I'd like to update a count as I type. This is easy to accomplish in most browsers with something like this on the textarea tag: onkeyup="document.getElementById('size').innerHTML=this.value.length; Howe...

How can I determine the element type of a matched element in jQuery?

I'm matching ASP.Net generated elements by ID name, but I have some elements which may render as text boxes or labels depending on the page context. I need to figure out whether the match is to a textbox or label in order to know whether to get the contents by val() or by html(). $("[id$=" + endOfIdToMatch + "]").each(function () { ...

Can't set IHTMLEventObj2::fromElement

I'm trying to generate synthetic Javascript events in an Internet Explorer extension, and I'm having trouble getting the fromElement property to stick. Here's an excerpt of my code: MsHtml.IHTMLDocument4 doc4 = ... // the document object Object o = null; MsHtml.IHTMLEventObj2 eObj = (MsHtml.IHTMLEventObj2)doc4.CreateEventObject(ref o);...

Why are commas inserted when innerHTML is copied after Postback?

This case is going to sound complicated, but it's not that bad. The javascript at the end of this code seems to be sound. EDIT: Here's the page running on a live server. The first example doesn't alternate between open and closed because I ripped out a lot of code in order to narrow the example down as much as I could. http://69.64.80....

Relative Image URL in Javascript File - ASP.net MVC and IIS 7

I am developing an Asp.net mvc application, everything works fine in ASP.net development server but when I am trying to host it on IIS 7. I am getting problem related to URL resolution. I have used relative paths in Javascript to give the image. The script file is in ~/Scripts/ folder and image files are in ~/Content/images/ folder. Now ...

Shorten URL value as Javascript variable

I'm using the jQuery Treeview plugin for navigation on a site with nested levels of categories. In each category there are then products, each of which have one or more information types. So my URLs can be either: foo.com/view/cat_id/ foo.com/view/cat_id/prod_id/ foo.com/view/cat_id/prod_id/info_id/ Trouble is, the navigation for th...

How do I slideDown whilst maintaining transparency in jQuery?

I'm trying to animate a block level element using jQuery. The page loads with the element styled with display: none. Id like it to slideDown whilst transparent and then fadeIn the content using the callback, however slideDown appears to set the visibility to full before fadeIn is called, resulting in the content being visible during the ...

Sorting domain names

Has anyone implemented sorting a list of domain names? I have seen some applications sort them as flat strings, but the problem is that you end up scattering all the related hosts in a domain: a.me.com a.you.com b.me.com b.you.com So, the basic logic I came up with reverse the order of the labels, then sort. FQDNs of one label should...

Hide a section in MS CRM form which contains read only field

Javascript I have code that will hide various sections in a MS CRM form based on the value of a Picklist. The code executes in the onChange event of the Picklist. It hides the section by referencing a field in the section and then navigating up the DOM using the ParentElement syntax, as such: crmForm.all.fieldName.parentElement.paren...

How to trim string in ClientValidationFunction

I am writing a client-side validation function for CustomValidator and I need to check length of entered string. But before, to counteract cheaters a little, I want to remove all leading and trailing spaces from the string. What is the easiest way to do it in this scenario? Thank you! ...

Does getElementById work on elements created by javascript?

I've created two functions to load expanded views of a month in the archive section of my blog when it's link is clicked: // Load open view of a month in the Archive section function loadMonth(date) { // Remove other open month removeMonth(); // Hide opening month's link // Define variable to hold month anchor tag var m...

Why does the javascript onchange event not fire if autocomplete is on?

I have a textbox with an onchange event. Why does this event not fire when the user uses the autocomplete feature to populate the textbox? I am working with Internet Explorer. Is there a standard and relatively simple solution to workaround this problem, without me having to disable the autocomplete feature? ...