javascript

Any difference between a $ wrap function and getElementById?

I mean a wrap function like this: function $(id) { return document.getElementById(id); } but in some code like this: oDiv1 = $("postInfoDiv"); oDiv2 = document.getElementById("postInfoDiv"); alert(oDiv1 == oDiv2); // return false alert(oDiv1.style); // error alert(oDiv2.style); ...

PHP: How should I escape a string that will be going into a Javascript String?

How should I escape a string that will be going into a Javascript String? URLEncode(X)? str_replace("'","\'",X)? ...

Quoting and escaping text strings advice

I am mainly C++ programmer who returns to PHP seasonly. Every time I return I spend time to get used to echo/print correct JavaScript/HTML/CSS regarding the single quote and double quote ...etc. I need an advice in the form of a set of rules to follow for good escaping practice. Edit This is a small example for my bad working code tha...

How Can I Trigger a Scanner from a Browser?

I have Fujitsu fi-6130 TWAIN / ISIS scanners that I'd like to trigger from a button in a jQuery Rails web page. Not only would I like to have the page tell the scanner to "go", I'd also like to upload the resulting file via Paperclip once the (single) page is scanned - ideally without requiring the user to navigate a file explorer widge...

thematic map: mouseover

i am generating a chart map like this: &chtm=usa">http://chart.apis.google.com/chart?chs=440x220&cht=t&chco=CBD122&chld=US&chd=s:&chtm=usa does anyone know if there is a feature to do something on mouseover? like have each state turn a different color on mouse over? ...

Add Additional Objects to JSON Encoded Array

Hi, I am currently using a JSON encoded array to display the users in my database for an auto-suggest feature. It looks something like this: $sth = mysql_query("SELECT id, name FROM users"); $json = array(); while($row = mysql_fetch_assoc($sth)) { $json['name'] = $row['name']; $json['id'] = $row['id']; $...

Help changing image slider from img's to li's

Hi. I've spent numerous hours trying to figure out how to get this slider to use li's with background images rather than img's. The reason for this is that I intend to use the slider for Wordpress & many Wordpress themes apply their own css properties to images (such as 'max-width') which will often break the slider. I would appreciate ...

build json object in javascript to post to php

I have a group of radio buttons in a form, I need to pass the values of the selected radion buttons to a php script. So I need to build a json object to post. I tried with this code, but I'm not sure. Please could anyone help me. result = []; for (i=0; i<document.getElementsByTagName('input').length; i++) { if (document.getElements...

How do I add a callback function to .submit() in Javascript?

I am submitting a page onclick of a form element and need a function to run after the submit refreshes the page. I'm trying to add an animated scroll back to the clicked element that caused the submission. I've got the scroll part covered but I can seem to figure out how to cause the function I wrote for the scroll to run after the page ...

if statement inside while loop. Why is it doing this?

I am using this: //if in landscape mode while(window.orientation == 90 || window.orientation == -90) { if(!$('#page' + hiddenNextPage).hasClass('showUp')) { $('#page' + hiddenNextPage).addClass('showUp'); $('#page' + hiddenNextPage).css('margin-left', '300px'); ...

how a cursor blinks in jQuery text editor?

Hello friends, I am just trying to know a text editor works ( jquery ), I found many jquery text editors on web. My question,the editor itself is not a textarea but an iframe I think, but How the cursonr blinks like a cursor in text area please check this http://batiste.dosimple.ch/blog/posts/2007-09-11-1/rich-text-editor-jquery.html ...

Javascript not working

I have a JavaScript function, in this function i will write <script type='text/JavaScript' language='JavaScript'>alert('ha')</script> But while executing this page it doesn't work. This is my code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; <html xmlns=...

validating event getting fired twice in maskedtextbox vb.net

I am facing a issue while using the "validating" event of the maskedtextbox. I have an MDI form, in which there is a main form and another form acting as bottom bar. The bottom bar comprises of buttons for moving to "previous" and "next" forms. If suppose in the main form i have a maskedtextbox and the initial focus is set on it, then on...

How do I check with jQuery if an element has at least one class, from a list of specified classes?

Example html: <div class="red"></div> <div class="green"></div> <div class="blue"></div> <div class="apple"></div> I want to loop through the divs and filter them out if they don't have a class of either 'red', 'green', or 'blue.' var onlyColorDivs = $('div').hasClass( ____ ); Is there a way to fillin the blank in the previous line...

Hide a table and change some text

I need to write a little Javascript to hide a table (by adding the hidden style class) and then change the text of the link to represent the state. The hiding part works but the changing of text does not. Here's the javascript... function toggle(idToHide, hiderID) { var element = document.getElementById(idToHide); var hiddenCla...

Model-View-Presenter lifecycle management in a plug-in based GUI

When a GUI is composed of several subcomponents that I treat as individual Views with their own Presenter and Models, is there a pattern for gluing them together? Some subcomponents are persistently on the screen while others would get swapped in and out. What would be a good factory pattern for instantiating the respective MVP triad f...

Controller actions being called twice --- Php application

Hello, I'm new around so if I'm missing some info or something, please let me know and I'll provide it. I've already looked for informationg regarding this error, but I haven't found anything relevant yet. So, here's the deal.. Some of my controllers actions are being called twice, and I've just noticed that when I was wondering why was ...

How can I implement WCF/OData access as a "paid upgrade" to my ASP.NET site if I want to use AJAX with the same?

Suppose I'm entertaining a business model that offers free access to my propritary data if they visit my website. These users will have advertising subsidize the cost. Then, for the paid users I want to offer direct raw WCF access to my data as an incentive. I don't want this available to the freebie users, but at the same time the si...

Setting var to sum of two textbox values is 0, how come?

I am experiencing something odd, please see below. Why is alert 1 outputting 0 but alert 2 outputting the correct sum? They are set to the same thing... var sumTotal = parseFloat($('#tb1').val()) + parseFloat($('#tb2').val()); //tb1.val() == 3, tb2.val() == 5; 1) alert(sumTotal); //Outputs 0; 2) alert(parseFloat($('#tb1').val()) + ...

compare "array of words" against textarea with php

I asked this question yesterday: http://stackoverflow.com/questions/3495735/compare-array-of-words-to-a-textarea-input-with-javascript Now I want to do the same thing with php... Is there any easy code for this? Thanks UPDATE: I would like to test the textarea input against the array, and if match of bad words found, die(); Thanks ...