jQuery is even easier than that. You can remove the need to put your
onchange inline like so:
var formAction = null;
$("select[name=some_name]").change(function() {
formAction = $(this).parent().attr("action");
});
This binds the anonymous function to set the variable formAction, to the
change event of the select.
-- Josh
----- Original Message -----
From: "briandichiara" <[EMAIL PROTECTED]>
To: "jQuery (English)" <jquery-en@googlegroups.com>
Sent: Thursday, May 08, 2008 12:18 PM
Subject: [jQuery] Getting Parent Element using "this"
I have a page where I need to get a parent forms action after firing
the onchange event on a select, like so:
<form action="something">
<select name="some_name" onchange="changeAction(this);">
<!-- some options -->
</select>
</form>
I can't figure out how to use "this" + a selector with jQuery,
I've tried
function changeAction(elm){
var formAction = elm.$(":parent form").attr("action");
}
I really have no clue how to do effectively use "this" + a selector.