javascript

adding img in js

I'm using javascript to create an image element like so: var img = document.createElement('img'); What would I do to give this img a width of 100%? ...

How to change cell's background color in SlickGrid ?

I was trying to change cell's background color with custom formatter like this: var myCellFormatter = function(row, cell, value, columnDef, dataContext) { if ((row + cell) % 5 == 1) { return "<div style='background-color:green'>" + value + "</div>"; } else { return value; } }; but this does not color the wh...

Form submit in javascript

Hi been wrestling this form and the last step (actually submitting) has me scratching my head. What I have so far is the form: <form id="theForm" method='post' name="emailForm"> <table border="0" cellspacing="2"> <td>Email <span class="red">*</span></td><td><input type='text'class="validate[required,custom[email]]" size="30"></td></tr...

Javascript Object Required error when scrolling page.

I have a page that uses the ModalPopupExtender. The popup can do some functions on it, and is kept open using ModalPopupExtender.Show() server-side. Whenever I do something other than closing the popup, I start getting javascript "object required" errors at line 2, but only when I try to scroll up and down the page. The popup is ope...

Special character in "entrée" cannot be displayed correctly if defined in a separate javascript file

Example: The following string is defined in a json.js file. var test = "One complimentary entrée with the purchase of an entrée."; It is included in an index.html file by <script type="text/JavaScript" src="./json.js"></script> When the string is displayed in UI, it shows up as "One complimentary entr�e with the purchase of an...

Evaluation of jQuery function variable value during definition of that function

I have a large number of rows in a table within which I wish to attach a unique colorpicker (jQuery plugin) to each cell in a particular column identified by unique ids. Given this, I want to automate the generation of instances of the colorpicker as follows: var myrows={"a","b","c",.....} var mycolours={"ffffff","fcdfcd","123123"...} ...

How do I get this web-based word processor?

Hi I was wondering if I could get a web-based word processor just like the one here on stack overflow, that shows a view of what you are typing in. ...

How do I disable form submit with enter key?

I have a js event on enter keypress which works fine. But after that event it also submits the form which has a submit button. How do I stop that submit button from getting focus after the previous keypress event? EDIT: I DONT WANT THE SUBMIT BUTTON TO SUBMIT ON ENTER, ONLY ON CLICK. ...

calculate number of working days on a rails form

I have two fields, 'from_date' and 'to_date' on my rails form. When a user enters the dates I have to display the number of working days i.e, exclude (sat, sun and a list of other official holidays in a database table). Is this something that should be done in the client side javascript Or is this something that should be done by maki...

Access-Control-Request-Header: - x-requested-with

Hi Guys, I am building a widget for my users and trying to get it working however I keep running into a X-Domain issue with this header. httpfox gives me - NS_ERROR_DOM_BAD_URI - and on further investigation I find that its Access-Control-Request-Method: GET Access-Control-Request-Header: x-requested-with I am not sure why its not...

How to access a variable outside a function in Javascript

Here is the code I am working with: $(document).ready(function () { var TemplateEditor = function () { var GroupClassName = 'group'; var SelectedGroup = 0; var BindClicks = function () { $('.CriteriaSelections').unbind('click').click(function (event) { event.preventDefault(); ...

JQuery validation using is() and multiple CSS classes

Hi Folks, Trying to debug something that basically .trim()'s, .val()'s and .length's a textarea input as HTML below (truncated): <form id="Kontaktanfrage" method="post" action="tests/testform/"> ... <textarea cols="50" rows="8" id="el_12" name="FORM[Kontaktanfrage][el_12]" title="Ihre Nachricht: *" class="textarea required"></textarea> ...

javascript ajax help

I have the following code. var d3_ad = 1; function displayD3Ad(){ var query_string = '?d3_ad='+d3_ad; query_string += '&location='+escape(location); //document.write('<iframe src="index.php'+query_string+'"></iframe>'); var data = httpRequest('http://localhost/test/index.php','GET',query_string); d...

how does google maps javascript bypass the "Same Origin Policy"

Hi there Just out of curiosity I was wondering how is it possible for the javascript code to embed google maps communicate with server from outside domain. I know I'm missing out something here. can anyone help? thanks ...

Javascript ContextMenu on a TD

If I attach a context menu to a td, it fires okay for text in the TD, but if I add a div to the TD, the context menu will not fire when right clicking on the div. How can I make the context menu fire when anything, data or divs, are right clicked in the td? Edit: The event was popping, but due to an error in my code, I never saw the ev...

Show/Hide RichFaces component onclick client-side? (without AJAX)

I'm looking for a way to show/hide an arbitrary RichFaces component. In this case, I have a <rich:dataTable> that contains several rows. Each row needs to have it's own, independent Show/Hide link, such that when you click "Show details", two things happen: The "Show details" link is re-rendered as "Hide details" The associated details...

dynamically insert javascript into <head> tag.

I am using CEWP (webpart) and putting this code in there. But this code is not going inside <head> tag. I need to insert this code in <head> tag, <script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt; <script type="text/javascript"> $("*").each(function () { if ($(this).children().length == 0) { $(this).text($(this).t...

What is the best way of converting SVG file into Raphaël?

I'm trying to open simple vector graphics using Raphaël JS and I can't find any converter that would do the whole job. Is there any way to transfer vector graphics (SVG or anything from Illustrator, Inkscape) into Raphaël's JavaScript? ...

Javascript how can I trigger an event that was prevented

In my app a user clicks a link to another page. I'd like to track that in Omniture with a custom event, so I've bound the omniture s.t() event to the click event. How can I make certain the event fires before the next page is requested? I've considered event.preventDefault() on the click event of the link, but I actually want the origin...

One-liner javascript to collect values from object graph?

Given the following object graph: { "children": [ { "child": { "pets": [ { "pet": { "name": "fido" } }, { "pet": { "name": "fluffy" } ...