javascript

Accessing javascript variable from HTML page in same domain?

I am attempting to enhance a internal web application we use. I am using a custom favelet to autopopulate certain fields. The javascript variables I need to populate a form exist on a different HTML page internally. Is it possible to access vars from another html page? They would be embedded in the external pages document element. I do ...

Send post-variable with javascript?

Is it possible to send post-variables with javascript? I want id to be sent with post, not get. window.location.href="hanteraTaBortAnvandare.php?id=10"; ...

The best way to handle a change in 'this'

A problem I regularly come across writing javascript using jQuery is that when a method of an object involves adding an event listener 'this' changes from being a reference to the object, to being a reference to the DOM element that triggered the event. Currently if I want to refer to the object from within the event handler I do someth...

best way to build dyanmic pop up menus

I have a scheduling page that display a week (sunday to saturday) schedule. They way I want to add employees to this schedule is with a series of popup menus that change based on the values selected. For example the first menu will be Jobs with <option> values propagated from the jobs table in my db. Now say a user selects 'Cook' in t...

How can I make a javascript variable and use it with jQuery

How can you make a javascript variable and use it with jQuery? I use the following command unsuccessfully in trying to get the POST data out of the var answer. I can access the variable in HTML by $_POST['answer']. var answer = $('#answer').val(); I use this variable in this code jQuery('div.answer_' + $answer + ' a.delete_answer') ...

Alternative for JavaScript onUnload

Hi, there is an alternative to the Javascript onUnload? I use JSP Jakarta Struts framework with a Servlets. I must know, when is window closing, because not everyone clicks on Logout button. How do you handle it in your applications? ...

JavaScript prototyping tutorial

I have a JS script with tons of functions, on big on is this: function id(i) { if(document.getElementById) return document.getElementById(i); return; } It just saves me many bytes in typing out document.getElementById() each time. My problem is I frequently add and remove classes and other attributes from elements. I w...

Is it bad to Base62 encode a javascript file?

I just found Dean Edwards javascript packer here: http://dean.edwards.name/packer/ It has a couple of options, Base62 encode Shrink variables To test it I took the latest version of jquery that is already minified to 56kb and ran it on that page above with shrink variables, the result is the same size file, 56kb. I then ran ...

Getting values from external input fields generated by jQuery

I will try to explain the situation as it is a little bit more complicated. I have created a multiple picture upload form. It works like this: In the form there are 2 submit buttons. 1 normal HTML submit button and another one is generated by jQuery. It is a "Browse" button which allows you to browse pictures on your HDD and add them ...

distance between 2 postcodes

I am using Google Maps API to get the distance between 2 UK postcodes. var yourPostcode = $("#YourPostcode").val(); var restaurantPostcode = $("#Postcode").val(); var point1 = GetPointFromPostcode(yourPostcode); var point2 = GetPointFromPostcode(restaurantPostcode); var distance = point1.distanceFrom(po...

Javascript DropDown Menu

I was looking to implement such menu as http://www.fogcreek.com/FogBugz/learnmore.html (Left hand side) Can anyone recommence some plug-in for jquery, or any other JavaScript library which behave same as above site? ...

How to position div in the center of the screen?

Actually in the center of current view, above all other objects. Cross-browser and without 3rd party plugins and etc. Via CSS or Javascript UPDATE: I tried to use Javascript's Sys.UI.DomElement.setLocation() but this positioning object not in absolute location but relative to it's parent. Is there a function to put in absolute locatio...

How to dynamically change the height of a div

How do I dynamically change the height of a div. Why does this not work: var priceBarElement = $("priceBar"); priceBarElement.style.height = request.responseText+"px"; Which I hope to use to change the priceBar div which is given by this line further down. <div id="priceBar" style="width:28px;margin-top:20px;background:#F00"></di...

How can I add a "selected" style to a siFR a:link?

I got a menu powered by SIFR like this: <h2><a href="images/logo.jpg">IDENTIIES</a></h2><br> I've setup the different states of the a:link style and I'd like this link to stay in another color when it has been clicked on (until another link is clicked on). I think this has something to do with javascript, but I can't make this work. ...

get json array back through javascript in jquery

Hey I have an external file in php, outputed as json format I want the data to be send back to jquery in arrays .... how to do it ? php: $options = "<option value="data0">data 0<option> <option value="data1">data 1<option> <option value="data2">data 2<option> <option value="data3">data 3<option> <option value="data4">data 4<option...

What are the security considerations for a javascript password generator?

For the longest time I was considering using a Javascript bookmarklet to generate the passwords for the different sites I visit to avoid the problem of "similar passwords everywhere", yet still be portable. However, after reading this paper it became clear to me that using this method would mean that a single malicious page could comprom...

serialize/unserialize in jQuery

Is there something like serialize/unserialize PHP functions in jQuery? These functions return a string representations of an array or an object which can than be decoded back into array/object. http://sk2.php.net/serialize ...

jQuery + hidden input fields

A simplified version of problem I am experiencing: Here is my HTML form: <form enctype="multipart/form-data" method="post" action="/controller/action"> <input type="text" name="title" id="title" value="" class="input-text" /> <input type="hidden" name="hidden_field" value="" id="hidden_field" /> <input type="submit" name="submit_form" ...

How might I add and calculate a "total" column using JavaScript?

Some time ago, people here helped me very well with code. Now I'm tasked with adding a small function: I really like to count the winning numbers which are defined in picks. Can somebody explain/edit the code for adding a extra column behind the last column with the total of green/winning numbers? Here is the website: http://www.cold...

Check that variable is a number

How can I check that a variable is a number, either an integer or a string digit? In PHP I could do: if (is_int($var)) { echo '$var is integer'; } Or: if (is_numeric($var)) { echo '$var is numeric'; } How can I do it in jQuery/JavaScript? ...