javascript

attachEvent inserts events at the begin of the queue while addEventListener appends events to the queue

I use this simple working function to add events: function AppendEvent(html_element, event_name, event_function) { if(html_element) { if(html_element.attachEvent) //IE html_element.attachEvent("on" + event_name, event_function); else if(html_element.addEventListener) //FF html_element.addEventListe...

How to prevent google chrome from caching my inputs, esp hidden ones when user click back?

hi there, i have an asp.net mvc app which have quite a few hidden inputs to keep values around and formatting their names so that i can use the Model binding later when i submit the form. i stumble into a weird bug with chrome which i don't have with IE or Firefox when the user submits the form and click on the back button, i find that ...

Separating Javascript and Html, when dynamically adding html via javascript

I am currently building a very dynamic table for a list application, which will basically perform basic CRUD functions via AJAX. What I would like to do is separate the visual design and javascript to the point where I can change the design side without touching the JS side. This would only work where the design stays roughly the same(i...

how to get the jsp page id to the javascript?

hi i am using jsp, in that one i used search box with 'id' i want to read that id to javascript file... but document.getelementbyid() is not working... ...

How do you override inline onclick event?

This seems deceptively simple. How do you override the onclick event in the following HTML using JavaScript? <a id="sample" href="..." onclick="alert('hello world')" />...</a> I've tried it with jQuery, but that didn't do the trick: $('#sample').attr('onclick','alert("done")') Assume the HTML is pre-written and cannot be changed, ...

How can I pass results from a callback via an object?

I am performing a Google local search, and wish to return the lat/long via an object. The Google search itself works fine. When inspected (using console.log or alert()) in the object itself, the results field appears to be populated OK. However, when inspecting the instance of the object (instantiated before running the callback) the...

problem in using appendchild in IE7

Find below the js function that I'm using to add a new date field & 'Select Venue' link to an existing div with id 'coursedates' . Problem is this works fine in FF 3 & IE 8. It doesnt work in IE7. If I alert the count(length) of 'dts' it always says 1, though it IE developer toolbar shows that the new date div is added to coursedates. I...

Simplest possible table entry editing / addition / deletion web toolkit (for use with php)

Hi, i'm building a website in php and i have tables presented that i need to allow the user to: 1. add new entry (only one at a time, which should appear as a new modal overlay) 2. delete multiple selected entries from 3. edit an existing entry (only one at one time, in a view similar to 1.) 4. re-arrange entries up and down. One by one...

Request periodically coming back empty under race conditions

I'm wondering if anyone has any suggestions as to what the possible cause of the following might be. I am using an autocomplete script with the following code: if (that.currentAjaxRequest !== null) { that.currentAjaxRequest.abort(); } that.currentAjaxRequest = $.get(query_string, function(data) { ...

possible to shrink contents of iframe?

Is there a way to shrink what's inside an iframe without adjusting css? any magical 'zoom' parameter out there?!!! I have a 600px preview iframe i want to fit a 1000px site in without scrollbars... ...

Reduce multiple ORs in IF statement in Javascript

Is there a simpler way to rewrite the following condition in JavaScript? if ((x == 1) || (x == 3) || (x == 4) || (x == 17) || (x == 80)) {...} ...

Styling a textarea with JavaScript

Hi guys! I'm absolutely new to JavaScript and would like to modify a textarea of a form (which is generated by an external script) as follows: 1.) Textarea on start: Labeled 'Your message here' in color 'rgb(136, 136, 136)' 2.) Textarea on focus: Label removed and color set to 'rgb(0, 0, 0)' 3.) Textarea on blur: Color of user input s...

How to load jQm modal on page load?

Hi I am using jQm Window to load modal window. http://dev.iceburg.net/jquery/jqModal/#how i am trying to jqmShow Show jqModal element(s). $('#dialog').jqmShow(); $('.dialogs').jqmShow(); but it throws some JS error, but it does not load on the page load, please guide me for the same. TIA ...

Javascript regex returning true.. then false.. then true.. etc

I have a strange problem with the validation I am writing on a form. It is a 'Check Username' button next to an input. The input default value is the username for example 'betamax'. When I press 'Check Username' it passes the regex and sends the username to the server. The server behaves as expected and returns '2' to tell the javascript...

What do I use to make a simple html gallery?

i'm trying to make the typical ecommerce site where you have different views of clothing and when you click it it becomes the main image. I'm assuming javascript would be best suited for this? maybe Jquery will be easier? Thanks I just need someone to point me in the right direction. ...

How do I pan the contents of a div when the right mouse button is dragged?

I need a cross browser way of capturing the right mouse click, preventing the default context menu and making it where when the user drags the mouse they can pan the contents of a div. This is largely similar to Google maps in that they will grip the contents and drag to see what they want. No external libraries please. I am already...

How to Configure SSL inside Firefox extension?

Hi, Can anybody explain how SSL can be configured inside a Firefox extension? I have a client who wants to connect to an https server and download some contents. My problem here is I don't know how to configure the communication between the client and the server inside the extension. I would appreciate if somebody would explain this to...

JavaScript For Loop in XSL document

I have a peculiar problem with having a JavaScript for loop in XSL document. Here it goes: I am calling a JavaScript function on the click of a CheckBox. Following is what I wanted to do in the javascript function :: function SeelctAll() { for(var cnt = 0; cnt < 100; cnt++) { //Business Logic here. } } For th...

jQuery to find previous elements

Hi everybody, I have the following table <table> <tr class="ligneI"> <td class="col2b"><input type="text" id="desc" class="calcule"></td> <td class="col2b"><input type="text" id="price" class="calcule"></td> <td class="calculated_price">220.00</td> <td class="calculated_price">1800.00</td> <td><a title="" class="picto06 deleteLink" id=...

How to check whether the Input Text Field is visible or hidden in Javascript ?

Hi, I have an input text field which has style: "visibility: visible" or style: "visibility: hidden" What is the easiest way to find out if it is visible or not ? Suppose the input text field is E. What should be the condition here: if <something with E> { alert("The text filed is visible !!"); } ? Thanks in advance ! ...