javascript

Apply conditional statements within string output in JavaScript.

Hello, I'm using a jQuery plugin named "jParse" to parse an XML file like so: $('#content').jParse({ ajaxOpts: {url: 'data.xml'}, elementTag: ['title', 'description'], output: '<h2>jpet0</h2><p>jpet1</p>' }); As you can see, the "jpet" variables correlate with the elementTag array. How would I check to see if the jpet var contain...

Dynamically Auto-Linking instance variables to object functions in javascript / jquery?

Hey all, I'm trying to create a robust audio player in javascript (& jQuery). I know that there are other players out there, but I'd like to try creating my own (so please don't refer me to jquery plugins). This is essentially what I would like to do: Main.js: var player = new Player(AudioObj); // Audio object links to Audio class (n...

How to call a webmethod asynchronously and partially render a control ?

Hi all, I need to call a webmethod of a webservice asynchronously from code behind of a web page. In the callback function I need to bind a gridview and render it. I want to partially render that gridview in the callback function in codebehind. How to implement that? Is it possible to implement all these in codebehind without using ...

Using jquery, how to I animate adding a new list item to a list?

I have a simple javascript function that allows me to add an item to a list. Note that I use JQuery... function prependListItem(listName, listItemHTML) { //Shift down list items... $("#" + listName + " li:first").slideDown("slow"); //Add new item to list... $(listItemHTML).prependTo("#" + listName) } The 'listName' ...

Running jQuery call in Firebug Console

Sorry, new to Firebug. I really find being able to run javascript in the Firebug console window helpful. However, I don't seem to be able to run jQuery calls in the console. For example, in my executing javascript in my page, I may make the call to get a value: jQuery('#an_element_value').text() However, I cannot execute this in...

WOT Bookmarklet

I'm trying to write a bookmarklet that will allow me to view the Web Of Trust (WOT) ratings for all the links on a page before visiting them. While WOT provides their own bookmarklet, it is not very useful since you need to visit the page first before viewing the rating. This will be used on SeaMonkey, so I can't just install the WOT e...

embed flash in the background (hidden on the page)

Hey all, I'm trying to make an mp3 player that passes javascript events to a flash file. I'm not very saavy in flash so this may be a simple question.. but how do you make a "movie-less" flash file? Is it possible to just embed an actionscript file? Because that is really all I need to run. Side note: What is the easiest (and fastest) w...

Can I use php in javascript?

Begginer's question. Can I use PHP in javascript? For example in jquery, ... ... triggers.eq(1).post('<?php admin/categories/delete/'. $list['id']; ?>); ...

clear textbox after form submit

I have a form which posts using ajax and reloads the div underneath. I need the textbox to clear when the submit button is pressed. <form name=goform action="" method=post> <textarea name=comment></textarea> <input type=submit value=submit> </form> ...

js: how to prevent default action on selecting text and dragging dragable elements (such as images)?

so that it is cross browser ...

How to get a server-side variable into JavaScript

I want to pass a value to this JavaScript from the database (using datareader in asp.net(C#)). The script is from http://www.dynamicdrive.com/dynamicindex14/leftrightslide.htm I need to set a pass value in the below line: leftrightslide[cnt] = '<a href="MYWEBPAGE"><img src="MYIMAGE FRM DATABASE.gif" border=1></a>'; cnt++; So the val...

Which Javascript code editor supports plain text line numbering?

I need to add a text area that also has line numbering capabilities. I tried EditArea, but I couldn't make it work with text files. It would be ideal if it could highlight syntax for existing programming languages, but that would only be a side bonus. The main thing I'm after is line numbering for whatever I paste in it. Please only li...

Javascript "Invalid Date" error in Safari.

Hello, I've been trying to debug a script of mine and I can't get my head around what's wrong with this: var date = new Date("19871104071535".replace( /^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/, '$4:$5:$6 $2/$3/$1' )); alert(date); It works in Firefox, IE, Chrome but Safari gives me an "Invalid Date" error. Any ideas? ...

How to use prettify with blogger/blogspot?

Hi everyone. I'm using blogger.com to host some texts on programming, and I'd like to use prettify (same as stackoverflow) to nicely colour the code samples. How do I install the prettify scripts into the blog domain? Would it be better (if indeed its possible) to link to a shared copy somewhere? I have webspace on a different domain. ...

window.resize event firing in Internet Explorer

As you are aware, in Internet Explorer, the window.resize event is fired when any element on the page is resized. It does not matter whether the page element is resized through assigning/changing its height or style attribute, by simply adding a child element to it, or whatever -- even though the element resizing does not affect the dime...

setInterval is not working

Suppose I have a function: function chk(){ alert("Welcome"); } window.onload = chk(); setInterval("chk();", 5000); but it is not working but when I refresh the page it works for me. How can I fix that? ...

Nested ordered lists

Hi, have any of you ever had the need for a nested list like this: 1. Item 1 1.1 - Subitem 1 1.2 - Subitem 2 1.3 - Subitem 3 1.4 - Subitem 4 1.5 - Subitem 5 2. Item 2 2.1 - Subitem 1 2.2 - Subitem 2 2.3 - Subitem 3 2.4 - Subitem 4 2.5 - Subitem 5 Well, I know I cannot achieve that with pure HTML. It would be great ...

Using Ajax callback variable values in JQuery dynamic click handlers

I'm doing a simple ajax query which retrieves a variable-length list of values as JSON data. I'm trying to make a list based on this data which has click-functions based on the values I got from the JSON query. I can make this work just fine by writing the onClick-methods into the HTML like this: function loadFooList() { var list_ar...

Where to put custom JavaScript/Prototype code for an ActiveScaffold form?

I have a Select dropdown on the form of an ActiveScaffold. I am trying to hide some of the fields on the form if a particular value is selected. A [similar question][1] was posted to the ActiveScaffold Google Group, and the supplied Prototype code looks to do what I need, however I don't know where I need to add this. -- I tried taki...

xmlhttprequest has stop working

i am loading a page with xmlhttprequest it was working fine but now it is giving me only the number 4 output when i load the page it gives me only [ 4 ] output without[] i.e 4 how can i fix that ...