javascript

JavaScript Concat

Via jquery / Javascript Given a number 1234567891234 How can I concat, or truncast By removing the 2 from the left to make that number a valid integer I can insert into MySQL:' 4567891234 Thanks This question edited by someone other than the OP, who's trying to guess at what the OP wants. Bear this in mind, but I think he wants to...

How to count the number of listitems in an asp.bulletedlist with JavaScript

Hi I have an asp:bulletedlist control, which sits inside a div tag, and I need to count the number of list items inside the control. Searching the internet, and noting the fact the html given back by the items is a list i.e. <li>, I thought I could use an example of: var listcontrol = document.getElementById('BulletedList1'); var count...

How can I replace all occurrences of a dollar ($) with an underscore (_) in javascript?

As the title states, I need to relace all occurrences of the $ sign in a string variable with an underscore. I have tried: str.replace(new RegExp('$', 'g'), '_'); But this doesn't work for me and nothing gets replaced. ...

Image resizing client-side with javascript before upload to the server

I would like to know if it is technically possible to resize an image at a client-side with javascript (really resize, not just change width and height). I know it's possible to do it in flash but I would like to avoid it if possible. Is there any open source algorithm somewhere on the web? ...

.net MVC, dealing with json and Areas

When not using areas dealing with the url for the JsonResults from the clientside is not much of a pain, usually you can get away with hardcoding the url into your json calls and get away with it. Problem arises when you have different areas and you don't want to update all your links when you move a controller (and its views) from one a...

Zend headScript() and appendFile not working as expected

I'm having an issue trying to append a javascript file using headScript()->appendFile('file name') with Zend. I have my layout setup like this: <?= $this->headScript() ->prependScript( 'BASE_URL = "' . $this->baseUrl() . '";' ) ->appendFile( $this->baseUrl('js/lib/jquery/jquery-1.4.2.min.js') ) ->appendFile( $this->base...

Solr JavaScript transformers and special characters (æ, ø, and å)

I am running Solr 1.4 with the Jetty web server. I have a transformer, written in JavaScript in my data-config.xml file, that looks as follows: <script><![CDATA[ function transform(row) { var itemColor = row.get('ItemColor'); if (itemColor == 'SORT' || itemColor == 'BLACK') { row.put...

Use array as jQuery POST Variables?

When sending data via POST or GET with jQuery you use for format { name:"value" } so i thought, is there a way to do it with this kind of code: var postdata = array(); postdata['name'] = "data"; $.post("page.php", postdata, function(data) { alert(data); } I tried this, and it doesn't seem to work. Is there a proper way to do this?...

Javascript in XSL that is loaded by Javascript

Is there anyway to have javascript run when a XSL sheet has been applied to an XML file by Javascript? I am using a JQuery plugin to apply the sheet to the xml but the javascript that is located inside of the XSL file will not run. I put the Javascript at the bottom of the file and it still does not run.. I can't seem to get an alert t...

ajax/html/javascript solution to disableing button for report generation and then reneable

I have a controller (Spring-MVC) that generates a PDF report on a get request. The controller sets headers like "application/OCTET-STREAM", "Content-Disposition", "attachment; filename=\"" + filename + "\"" so that the user gets the save/open dialog forced to them. The controller gets a pdf generated and writes the pdf bytes directly t...

code snippet works when procedural, but doesn't when converted to modular

function sc_HTMLParser(aHTMLString){ var parseDOM = content.document.createElement('div'); parseDOM.appendChild(Components.classes['@mozilla.org/feed-unescapehtml;1'] .getService(Components.interfaces.nsIScriptableUnescapeHTML) .parseFragment(aHTMLString, false, null, parseDOM)); return parseDOM; } becomes ...

How do I create a random method name

I plan on using JSONP to call an external webservice to get around the fact that I dont want to create a global function that could potentially conflict with the calling page. I thought that creating a random function name and passing it up would work. Something like this: <script src="www.foo.com/b?cb=d357534"> where cb is the callb...

Normalize whitespace and other plain-text formatting routines

Background: The language is JavaScript. The goal is to find a library or pre-existing code to do low-level plain-text formatting. I can write it myself, but why re-invent the wheel. The issue is: it is tough to determine if a "wheel" is out there, since any search for JavaScript libraries pulls up an ocean of HTML-centric stuff. I am ...

Best Practice: Access form elements by HTML id or name attribute?

As any seasoned JavaScript developer knows, there are many (too many) ways to do the same thing. For example, say you have a text field as follows: <form name="myForm"> <input type="text" name="foo" id="foo" /> There are many way to access this in JavaScript: [1] document.forms[0].elements[0]; [2] document.myForm.foo; [3] d...

Multiline values in dropdown (ComboBox)

Is there are any libraries to make ComboBox to select multiline options when expanded. I am looking something similar to Combobox in ExtJS except values have to appear when user clicks down arrow, like in normal dropdown. Does someone know if its possible to do something like that with ExtJS? Because their own community and support sur...

Returning currently displayed index of an array Javascript...

I have a simple array with x number of items. I am displaying them individually via a link click... I want to update a number that say 1 of 10. when the next one is displayed i want it to display 2 of 10 etc... I have looked all around and my brain is fried right now... I know its simple I just cant get it out. <!DOCTYPE html PUBLIC...

How order a view result by reduced value? CouchDB

Can I order the result of a view by the value, returned by reduced? { "rows": [ {"key":"bob","value":2}, {"key":"john","value":3}, {"key":"zztop","value":1} ] } I wanna a result like this: { "rows": [ {"key":"zztop","value":1}, {"key":"bob","value":2}, {"key":"john","value"...

How can I close a SimpleModal dialog when the user clicks the Back button?

When a user clicks on a button or link, I use the SimpleModal jQuery plugin to display a dialog to overlay the entire page, preventing the user from clicking another button or link during the delay before the next page loads. (I'd like to avoid this, but that's an issue for another day.) After the next page displays, if the user clicks ...

What are cons to use jquery sifr plugin over original sifr 3?

If I'm alreadu using jquery library on site then should i use origional sifr or jquery plugin. What are cons to use jquery sifr plugin over origional sifr 3? jQuery sIFR Plugin http://jquery.thewikies.com/sifr/known-issues ...

Old fashioned html onclick return false doesn't work inIE when jQuery script is included

Ok, so I'm quite new to jQuery, but found this bizzare problem just now, If we ignore jquery for a second and consider this scenario, if i have two links like below both with an href and both with and onclick event. The first link will not follow the href because the onclick returns false, and the second link will because the onclick r...