<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-15">
</head>
<body bgcolor="#ffffff" text="#000000">
<div class="moz-text-plain" wrap="true" graphical-quote="true"
style="font-family: -moz-fixed; font-size: 14px;" lang="x-unicode">
<pre wrap="">Hi Marc,
On Sat, 11 Sep 2010 08:37:59 -0400, Marc Delisle <a class="moz-txt-link-rfc2396E" href="mailto:marc@infomarc.info"><marc@infomarc.info></a>
wrote:
</pre>
<blockquote type="cite" style="color: rgb(0, 0, 0);">
<pre wrap=""><span class="moz-txt-citetags"></span>Hi,
<span class="moz-txt-citetags"></span>this works on a input element:
<span class="moz-txt-citetags"> </span>
<span class="moz-txt-citetags"></span>var this_name = $(this).attr('name');
<span class="moz-txt-citetags"> </span>
<span class="moz-txt-citetags"></span>so I'm trying to do the same to extract the code inside the onchange
<span class="moz-txt-citetags"></span>"attribute":
<span class="moz-txt-citetags"> </span>
<span class="moz-txt-citetags"></span>var this_onchange = $(this).attr('onchange');
</pre>
</blockquote>
<pre wrap="">
this won't work.
</pre>
<blockquote type="cite" style="color: rgb(0, 0, 0);">
<pre wrap=""><span class="moz-txt-citetags"></span>but Firebug tells me that this_onchange is an event;
</pre>
</blockquote>
<pre wrap="">yepp that's right
</pre>
<blockquote type="cite" style="color: rgb(0, 0, 0);">
<pre wrap=""><span class="moz-txt-citetags"></span>it does not contain the code. I need to do subsequent string matching and<span class="moz-txt-citetags">
</span>replacement in this code.
</pre>
</blockquote>
<pre wrap="">Please use a function call for this, and replace silly the params:
$(this).unbind('change');
$(this).bind('change', function(e) {
// your function call
// something like:
// pma_js_function_to_call(param1, param2, para,X)
});
Other solution is to work with a string, make your string replacement and
after this use the eval-function. Sample:
$(this).unbind('change');
$(this).bind('change', function(e) {
eval(your_replaced_string);
});
But eval is devil:
The eval function (and its relatives, Function, setTimeout, and
setInterval) provide access to the JavaScript compiler. This is sometimes
necessary, but in most cases it indicates the presence of extremely bad
coding. The eval function is the most misused feature of JavaScript.
Regards
Michael
</pre>
</div>
</body>
</html>