javascript

Reset an input control's border color (HTML/Javascript)

Does anyone know how to reset the border color of an input control once you have modified it using javascript? Useful for validation by highlighting fields that have incorrect or invalid data in them etc. E.g. changing the border: document.getElementById('myinput').style.border = '1px solid red'; how to reset? the next line just re...

How to HTML encode a string in JavaScript from a Firefox extension

So I know I can write my own HTML-encoding function like this: function getHTMLEncode(t) { return t.toString().replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;"); } But I was wondering if there were any native facility for this that is available to XPCOM components. I'm writing a component, not ...

Recommend a JS calendar widget that handles both date and time?

I'm working on a Web app where users need to input a date and time. I've used this calendar widget before and it works fine: http://www.dynarch.com/projects/calendar/ However, it hasn't been updated since 2005. I'm wondering if anyone knows of a better one. The calendar in jQuery UI doesn't handle times. Only dates. I need something t...

What JavaScript library to use for client-side form checking?

Over the years, I've dabbled in plain JavaScript a little, but have not yet used any JavaScript/AJAX libraries. For some new stuff I'm working on, I would like to use a js library to do client-side form validation, and want to know which would be best for that. By best, my criteria would be: quick and easy to learn, small footprint, c...

Chrome Doesn't Support QueryString

Dear all I am Extract the Data from the link. It works fine in firefox,But GoogleChrome didn't support.This functionality. Is there better way or alter procedure to extract the query string contents My Link http://safalra.com/web-design/javascript/parsing-query-strings/ <script type="text/javas...

John Resigs micro templating engine, question of how to handle selects?

I've a template that looks like so: <script type="text/html" id="TemplateEdit"> <td> <input type="hidden" value="<#= item.ID #>" id="Edit.ID" name="Edit.ID" /> <select id="Edit_ClientID" name="Edit.ClientID"> <option value="1">test</option> <option value="2">test 2</option> <optio...

Live username lookup with AJAX/Jquery

I want to have a javascript function such as this: function isUsernameAvailable(username) { //Code to do an AJAX request and return true/false if // the username given is available or not } How can this be accomplished using Jquery or Xajax? ...

hyperlinking for image

Dear all, I am using javascript to specify the target link. It is not working properly. What change should I do in order for it to work correctly. My code: var link = create_element(cell, 'img'); link.setAttribute("src", "images/sub.png"); link.href = "http://localhost/"; Kindly help me ...

Javascript variable scoping question

If I had a function like this: function validateSomething() { var valid; $.post("something.php", {x:y}, function(data) { if (isSomething(data)) valid=true; //Here referring to the valid variable //set outside this function, in the // parent function else valid=false; }); return...

Validating and Submitting a form using Javascript + Ajax

Here's what I'm trying to do. When the 'Submit' form is clicked on my form, a javascript function will loop through all the fields of the form. For each field a function will be called which would return true/false to indicate if it was filled in correctly or not. If a false is returned, it shows an error message next to that field. If...

Does .net/C# have an equvilent Javascript Object Proxy/Serialization like DWR in Java?

I have some old code in Javascript that interfaces to Java DWR. I'm looking to port the back-end to .NET/C# possibly, and I was just wondering if there was an equivalent AJAX framework that would work in the same manner as the DWR framework in Java. ...

How to transform HTML table to list with JQuery?

How would I transform a table <table> <tr> <td>Name</td> <td>Price</td> </tr> <tr> <td>Name</td> <td>Price</td> </tr> </table> to a list of paragraphs with jQuery <ul> <li> <p>Name</p> <p>Price</p> </li> <li> <p>Name</p> <p>Price</p> </l...

JavaScript versus google flash component... possible ?

Hi. I'm in JavasSript, but not in Flash, so maybe you can help me with this one. I have embed some audio on a page using the google component, as here : <embed type="application/x-shockwave-flash" src="http://www.google.com/reader/ui/3247397568-audio-player.swf?audioUrl=MP3_FILE_URL" width="400" height="27" allowscriptaccess="never"...

How to get data with JavaScript from another server?

How can I make requests to other server(s) (i.e. get a page from any desired server) with a JavaScript within the user's browser? There are limitations in place to prevent this for methods like XMLHttpRequest, are there ways to bypass them or other methods? That is a general question, specifically I want to check a series of random webs...

Programmaticly creating <DIV>s and problems arise

I am new to javascript and have written a piece of code (pasted below). I am trying to build a little game of Battleship. Think of that game with a grid where you place your ships and start clicking on opponents grid blindly if it will hit any of the opponents ships. Problem is I need to get a function called with the ID of the DIV to be...

ASP.NET MVC AJAX with jQuery

I have a site where each user's page shows comments and allows other user's to add comments. I want to have it so the add comments form is on the page and when a user adds a comment, it is added to the database and shows up in the comment section with AJAX. I am using jQuery for the AJAX and LINQ to SQL to handle the database logic. How ...

JQuery star rating plugin - disable after vote submission

Hi, I'm using the JQuery star rating plugin (v2.61) from http://www.fyneworks.com/jquery/star-rating/. Everything's going well, but I'd like to disable the stars when a user has voted. Currently my users select their rating and click the mouse. This updates my database through an AJAX call. The star rater changes to show the user's ...

How trustworthy is javascript's random implementation in various browsers?

I would like to do some experimenting with javascript and encryption and I got curious as to how unpredictable the implementation of the random function is. Has anyone done any hard tests? Clearly browsers have the ability to generate strong randomness (for ssl). The questions is do they give javascript access to the same strength. ...

Smooth scroll to top of page after an asp.net ajax postback

I have an error message area at the top of a long page. After an ajax postback in asp.net (using an update panel), sometimes I need to display an error message and it will be displayed outisde the viewport and the user might not notice it. I would like the return (same) page to scroll smoothly to the top of the page, rather than a sudd...

JavaScript Regexp Replace?

I'm trying to come up with a regular expression which will wrap all occurences of JJDnnnnnnnnnnnnnnnn within a string with an anchor pointing to an url which contains the matched string in the query string. I suck at regexps :( ...