javascript

Issue: Onclick triggered after onblur on Mac machines

Hi, We have a couple of textboxes in a form. All of which are validated onblur. The form is submitted onclick of an anchor tag. <script> function validateMyText(){ // do field validation // if success return true; // else { alert("Please check the text box value"); return false; } } </script> <form name...

Adding Counter to HTML Form and Calculate Credits

I have a simple HTML Form that allows the user to enter some text which is then sent as an SMS/TXT Message via an SMS Gateway. The user enters the message text into a textarea: <textarea rows="10" cols="40" id="smsbody" validate = "required:true" name="MessageBody"></textarea> They can enter as little or as much text as they like, how...

Scroll down at character number N in HTML

I can calculate an order of a character I would like to open a HTML page at. Is it possible (with jQuery) to write a script that will scroll down to a position of nth character in HTML markup? Let's say this is my HTML: <p>Hello</p> <p>Hello</p> <p>Scroll here</p> <p>Hello</p> How would I scroll down to 28th character in that HTML (...

Dynamically updating label text on textbox changes?

I want to display the text entered in a textbox on a label character by character. I.e, if I enter a character in textbox, I need to display that character in the label. Up to the length of the textbox, this procedure has to done for the label also. How can i achieve this? ...

setAttribute style not working in IE

Hello, Setting the style attribute to elements is not working in IE 6/7 . But in other browsers, it works well. The code i am using is var box_style = 'width: 200px; background:red'; document.getElementById('box').setAttribute("style", box_style); This works in all other browsers except IE 6/7 Am i doing anything wrong ? or is t...

How can I parse a HTML attribute value out of XMLHttpRequest.responseText?

The below JS function does Ajax request and retrieves HTML in obj.responseText. My issue is that I need to extract the value of id inside the span into notify_id var. I just don't know how to get that done. This is the HTML to lookup: HTML: <span id="1034"></span><img src="./images/icons/post_icon.png"> JS: function func() { ob...

JQuery handling multiple key presses in IE and Firefox

Hi, I'm working on handling the multiple key presses with jQuery. I have two handlers: 1. keyDownHandler 2. keyUpHandler keyDownHandler detects if the certain key has been pressed, if yes it sets a certain boolean value to true and carries on with the processing. keyUpHandler resets the boolean value to false. All this is required...

Simple way to monitor result of request to detect session timeout?

I've got an Ajax app I would like to add sessions and logins to. Currently the app uses jQuery get shorthand to send a request that.ajaxRequest = $.get(query_string, function(data, textStatus, xhr) { // do somthing with data }); I have a system on the server that throws an error message if the session has expired. On the client...

javascript error

My Script is working if <script type="text/javascript"> $(document).ready(function() { $('#holidayDate').datepicker(); var availableTags = ["New years Day", "Martin Luther King Day", "Groundhog Day", "Valentine's Day", "Washington's Birthday", "Easter", "Earth Day", "National Arbor Day", "Mother's Day", "Memorial Day", "Flag D...

How to load jQuery dynamically with Rails?

I have a page, where I load a partial (that contains a form) dynamically. So after that you click in a button, via jQuery I do a get, get the form and I change the html of a div. Everything works great. The problem is I have some javascript that I added inline on the partial and I would like to remove it. So in my partial I made some...

How to handle a not defined value in java script

How to handle a not defined value in java script if (oldins == ins) oldins is not defined How i check??????? ...

Adding @import statement in a dynamic stylesheet for IE7+

I have a problem with adding a dynamic style element with @import statements for IE. Try this: var string = '@import url(test.css)'; var style = document.createElement('style'); if (style.styleSheet) { // IE style.styleSheet.cssText = string; } else { var cssText = document.createTextNode(string); style.appendChild(cssText)...

JavaScript replace

I'm doing something like: <p>SQL</p> <p>sql</p> <p>sQl</p> <p>SqL</p> <script type="text/javascript"> var ps = document.getElementsByTagName('p'); for(var i = 0; i < ps.length; i++) { var p = ps[i]; p.childNodes[0].nodeValue.replace(/sql/gi, 'VB.NET'); p = null; } </script> But it's not replacing the text. What's wrong? Thank you....

Google API V3 mouseover and call

I am about to start implementing Google map V3 into a site that has a previous version of google maps. Is this a hard change to upgrade? Also do I need to add the api key to the call For example: the new call <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"&gt; the previous call <script src="h...

how do you redirect to a page as soon as a user enables their javascript?

i was wondering if there was some sort of event triggered when javascript is enabled in a browser (ie. in firefox, tools->options->check off enable javascript-> click ok). i want to redirect a user to a page when this happens. any ideas? Thanks! EDIT: i've put an iframe into the page but am not getting the alert (after i enable javascr...

Using XMLHttpRequest in a Google Chrome extension

Hello, I started making this simple google chrome extension in javascript. And in the beginning of the code I have the following: var req = new XMLHttpRequest(); req.open( "GET", "http://www.ldoceonline.com/dictionary/manga", true); req.onreadystatechange(alert(req.readyState)); The value req.readyState comes to be 1, w...

Escape "+" with JS and PHP

Hi, i have made an app, you write some text, and text will be saved over ajax. Before sending the request, i escaped it with js. But somehow, the "+" Character will be converted to " " Space Character... So i tryed to find and replace before sending in "%plus%" but i get thes error message: Uncaught SyntaxError: Invalid regular exp...

Is it possible to insert a line of javascript into external iframe ?

Possible Duplicate: how to add code into a iframe I want to add some javascript code into external iframe. How to do it ? I want to actually add ads code into iframe pages ? Please help me ...

On Submit - Check at least one checkbox

Hi, I have multiple check boxes. When the Submit button is clicked I want to check if at least one checkbox is selected. Its not working function doSubmit(){ function check_checkboxes() { checked=false; var c = document.getElementsByTagName('input'); for (var i = 1; i < c.length; i++) { if (c[i].type...

getJSON without Jquery

How to use getJSON() without jquery? ...