How to use a javascript funtion

how to use a javascript funtion which should run when i am clicking any
link or submit in whole form?
except in onclick tag (or) on submit tag

Pokkai D. wrote:

how to use a javascript funtion which should run when i am clicking any
link or submit in whole form?
except in onclick tag (or) on submit tag

don’t get, what exactly you want to do

link_to_function “Greeting”, “alert(‘Hello world!’)”
would create a link to a js function

otherwise you can implement onclick whereever necessary:
onclick=“alert(‘Hello world!’);return false;”

or combine it with onsubmit etc.

Thorsten M. wrote:

Pokkai D. wrote:

how to use a javascript funtion which should run when i am clicking any
link or submit in whole form?
except in onclick tag (or) on submit tag

don’t get, what exactly you want to do

link_to_function “Greeting”, “alert(‘Hello world!’)”
would create a link to a js function

otherwise you can implement onclick whereever necessary:
onclick=“alert(‘Hello world!’);return false;”

or combine it with onsubmit etc.

i want to do if there is any button or link is clicked then a javascript
function should automatically execute

I think the prototype equivalent is

$$(‘a’).onclick = function(){
}

however I am also more partial to the JQuery way. I have yet to have a
problem making them work together.

Just get this order right and you should be fine:

include jQuery
call “var J = jQuery.noConflict()”
include prototype

J(‘a’).click(function(){})

Pokkai D. wrote:

Thorsten M. wrote:

Pokkai D. wrote:

how to use a javascript funtion which should run when i am clicking any
link or submit in whole form?
except in onclick tag (or) on submit tag

don’t get, what exactly you want to do

link_to_function “Greeting”, “alert(‘Hello world!’)”
would create a link to a js function

otherwise you can implement onclick whereever necessary:
onclick=“alert(‘Hello world!’);return false;”

or combine it with onsubmit etc.

i want to do if there is any button or link is clicked then a javascript
function should automatically execute

simple with jQuery !

jQuery(‘a’).click(function(){
my nice code here
});

although, getting jQuery working with prototype is bit tricky. i use
jrails javascript files, but WITH prototype.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs