Answered
please help with some basic javascript syntax
Can anyone please help me with a "remove from favourites"
facility i'm working on.
I query to get all the favouites, then i output those favourites down the page
each favourite has a "remove from favourites" link - i want to make it so when a user clicks this link they get a javascript confirm box pop up saying "are you sure you want to remove #favourites name# from your favourites?"
so i have..
function remove(profile,name) {
if (confirm("Are you sure you want to remove #name# from your favourites?")) {
window.location = "remove_from_favourites.cfm?deleteFavID=#profile#&removedName=#name#"
}
}
and
<div onClick="remove(#rs_favs.favouriteeID#,#rs_favs.firstName#)" >Remove from favourites</div>
but it doesn't work - i think there are 2 problems..
problem 1 - i have used the CF # in the remove function as i don't know what one does in javascript to "output" a variable (see where it says "Are you sure you want to remove #name# from your favourites") what should i use in place of the "#"?
problem 2 - i have tried to pass to variables to the function >> onClick="remove(#rs_favs.favouriteeID#,#rs_favs.firstName#)" and i have separated them but a commer "," but i suspect that is incorrect syntax
if anyone could please help me i'd be very grateful as, to be honest, i love coldfusion - but javascript just hurts my head! :(
thanks very much indeed.
PS the way i've wrapped my "remove from favourites" text in a div rather than making it an actual "a href" link - is that right or is there a better way (ideally i'd like the text to look like all my other links (ie they underline on mouse over)
I query to get all the favouites, then i output those favourites down the page
each favourite has a "remove from favourites" link - i want to make it so when a user clicks this link they get a javascript confirm box pop up saying "are you sure you want to remove #favourites name# from your favourites?"
so i have..
function remove(profile,name) {
if (confirm("Are you sure you want to remove #name# from your favourites?")) {
window.location = "remove_from_favourites.cfm?deleteFavID=#profile#&removedName=#name#"
}
}
and
<div onClick="remove(#rs_favs.favouriteeID#,#rs_favs.firstName#)" >Remove from favourites</div>
but it doesn't work - i think there are 2 problems..
problem 1 - i have used the CF # in the remove function as i don't know what one does in javascript to "output" a variable (see where it says "Are you sure you want to remove #name# from your favourites") what should i use in place of the "#"?
problem 2 - i have tried to pass to variables to the function >> onClick="remove(#rs_favs.favouriteeID#,#rs_favs.firstName#)" and i have separated them but a commer "," but i suspect that is incorrect syntax
if anyone could please help me i'd be very grateful as, to be honest, i love coldfusion - but javascript just hurts my head! :(
thanks very much indeed.
PS the way i've wrapped my "remove from favourites" text in a div rather than making it an actual "a href" link - is that right or is there a better way (ideally i'd like the text to look like all my other links (ie they underline on mouse over)
