javascript

How do I make an automatic javascript function call from php function?

I am trying to create an auto-refresh for a table using ajax/jquery, php/html, and Drupal 6. Code once the database insert has finished and was successful: echo "<script type='text/javascript'>autoRefresh()</script>"; Code for the link that eventually calls the javascript code that actually performs the refresh of the table: $b...

What are your recommendations on a jQuery custom select element plugin?

I've seen quite a few online and I thought I'd consult the Stack Overflow community for which they may have experience with and can make recommendations. I basically am looking for a plugin that can replace a select element with custom dropdown that uses CSS (not tables) fair bit of flexibility with styles lightweight ...

In JavaScript, how can I create a function with an optional parameter?

Question: What is the proper way to define a function in JavaScript that takes optional parameters? For example: function myFunc(optionVar1) { if(optionVar1 == undefined) { ... } else { ... } } myFunc('10'); // valid function call myFunc(); // also a valid function call Is it proper to use a ? mark ...

Get index of select option in an optgroup with jquery

I have the following select: <select name="end" id="end"> <optgroup label="Morning"> <option value="12:00a">12:00 am</option> <option value="12:30a">12:30 am</option> <option value="1:00a">1:00 am</option> <option value="1:30a">1:30 am</option> </optgroup> <optgroup label="Evening"> ...

jQuery animate doesn't complete (slideUp/slideDown)

I have a web interface to a system which has a left navigation. On the navigation, I can expand/collapse some menus. I use jQuery slideUp/slideDown to animate them like this: if (enable) { navbar_slide_down = true; $j(l1_folder).slideDown("normal", function() { navbar_slide_down = false; on_navbar_animation_comp...

Fetching all (javascript) global variables in a page

Is there a way to retriev the name/value of all global variables on a page? I would like to write a javascript function to do the following: Find all global variables prefixed with 'xxx_' and stick them in an array (for e.g.) build a query string using the name value pairs as follows: xxx_glob_var1=value1&xxx_glob_var2=value2 etc C...

calendar in php

How can I make a calendar in php so that the users will not have to input the date manually. ...

Asp.Net Mvc - ContentPlaceHolder- Javascript

Depending on which page I am, I would like the content of a javascript function to change. Example : MasterPage <script type="text/javascript"> Cufon.now(); Cufon.replace('p#characters', { fontFamily: 'Helvetica95-Black' }); </script> Page A <script type="text/javascript"> Cufon.now(); Cufon.replace('p#characters', ...

JavasScript: Why does my_array.length not work?

Version 1: var spamfoo = new Array(); spamfoo.push(['name', 'url']); spamfoo.push(['dog', 'cat']); alert(spamfoo); // Alerts: name,url,dog,cat alert(spamfoo.length); // Alerts: 2 // ??? (shouldn't this be 4?) Version 2: var spamfoo = new Array(); spamfoo.push(['name', 'url']); spamfoo = spamfoo + ['dog', 'cat']; alert(spamfoo); // Al...

why my jquery code is ok in firefox,but not ok in chrome and ie8???

function tip(evt,s){ $('p#vtip').show(); xOffset = -10; // x distance from mouse yOffset = 10; // y distance from mouse top = (evt.pageY + yOffset); left = (evt.pageX + xOffset); var str = $(s, "> #content").html(); $('p#vtip #content').html(str); $('p#vtip').css("top", ...

Generate some xml in javascript, prompt user to save it.

I'd like to make an XML document in JavaScript then have a save dialog appear. It's OK if they have to click before the save can occur. It's *not* OK if I *have* to use IE to achieve this (I don't even need to support it at all). However, Windows is a required platform (so Firefox or Chrome are the preferred browsers if I can only do...

Wrap text and elements in another element using jQuery

I have a page which essentially looks like this: <div id="foo"> <a>One</a>, <a>Two</a>, <a>Three</a>, <a>Four</a> </div> Extra attributes removed for the sake of brevity. There could be any number of links inside the div. What I want to do is to hide all the links after the n th one and add a "Show the rest" link. Basically, for ...

replace html tag in html editor with specific string

hi anyone knows how to replace a html tag in a string with specific characters: e.g. string s1 = "<span style="italic">inluding <span style="bold">other</span> tags </span>"; string s2 = "<span style="italic">inluding </span><span style="bold">other tags </span>"; i want to replace "span" with "bold" to "bOpen" and "bClose" and to...

In JavaScript is it possible on IE to register one event listener to capture all the change, focus, and blur events on the page?

In non-IE browsers: The change event bubbles, so you can catch it when it gets to document in the bubbling phase. The focus and blur events don't bubble, but you can catch them on the capture phase with one event listener on document. On IE: None of those 3 events bubble (including the change event, which is not spec compliant). Ther...

keydown on body?

i want to focus an inputfield whenever i press a key. so i use: $('body').live('keyup', function() { alert('testing'); }); but it doesnt work. is it wrong with my selector? UPDATE: here is my code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; <html xmlns=...

Utilising JSON values in Javascript

I'm originally a PHP programmer and have been struggling with this for at least 2 whole 9-to-5 days now. I've come a long way but I seem to have gotten stuck trying to figure out the last bit. It SHOULD be fairly simple, but somehow I can't seem to find anything that coulp help me figure it out. I have the folliwing jQuery code that ret...

Detecting Hebrew words in document via JavaScript

Hi guys, I'm a mostly-newbie when it comes to web development (though not to programming in general) so pardon any incorrect terminology. I want to build a script that, when added to an HTML page, detects each Hebrew word in the page and transforms that word into an HTML element, e.g. into a hyperlink with title. So, the following: <...

why in firefox it is ok, but in ie8 it print 'undefined undefined'??

<div> <span onmouseover="tip(event,this);">程序错误<div class="content">good</div></span><br> <span onmouseover="tip(event,this);">程序错误<div class="content">good</div></span><br> <span onmouseover="tip(event,this);">程序错误<div class="content">good</div></span><br> <span onmouseover="tip(event,this);">程序错误<div class="content"...

Information bar like stackoverflow

Possible Duplicate: Stackoverflow Style Notifications in asp.net Ajax Hi, I am trying to make an information bar similar to the one here on stackoverflow. I found the Activebar jquery plugin. But I want to be able to customize it. I want a fading effect or a semi transparent background. Can someone please help. Thanks. ...

applying varying styled text

when i write a paragraph i would like the text to look like this: is it something that i have to do in css? i want similar formatting. ...