[EMAIL PROTECTED] ha scritto:
I have a page (edit.asp) which uses the .load() to load another page
into a div. Inside this loaded page (students.asp) is a select box
(id="classavailable") and a link (id="ajaxAdd").
I am trying to run an event after the user selects a value in the
select box and clicks the link. Right now, I just have it set up to
run an alert:
This is the jQuery on edit.asp, the main page:
function addClass() {
$("#ajaxAdd").click(function(){
alert($('#classavailable').val());
});
}
After a user selects a value and clicks the link for the first time,
nothing happens. If the link is clicked again (with no other
interaction) the function runs. If a user then changes the select
value and clicks the link, the function runs twice. If a user selects
a third unique value and clicks the link, the function runs three
times.
What I want is the function to run only once and when the link is
clicked. Can anyone tell me what I have overlooked?
Thanks!
- Seth
Maybe you are calling addClass when the user click on your link.
That would explain what you experience.
You should run
$("#ajaxAdd").click(function(){
alert($('#classavailable').val());
});
just once when you loaded page is complete.
Renato