Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / JScript / March 2004

Tip: Looking for answers? Try searching our database.

Dynamically calling a function from the client side

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
lester - 01 Mar 2004 20:26 GMT
I want to dynamically check on the client side to see if a control has an onchange event handler
and then if so, to call it.  Does this sort of functionality exist within javascript ??  It's sort of
similar to the SQL's EXECUTE( 'somestring' ) functionality

Thanks

LES
bruce barker - 01 Mar 2004 21:06 GMT
you can dynamically detect if a control has a handler, but you won't know
what parametrs it expects

<input id=text1 type=text onchange="doChange(this,'myData')">
<input id=text2  type=text >
<script>
   if (document.getElementById('text1').onchange != null)
      document.getElementById('text1').onchange();
</script>

-- bruce (sqlwork.com)

> I want to dynamically check on the client side to see if a control has an onchange event handler
> and then if so, to call it.  Does this sort of functionality exist within javascript ??  It's sort of
[quoted text clipped - 3 lines]
>
> LES
lester - 01 Mar 2004 22:46 GMT
Thanks !

I can get the string "doChange(this,'myData')" from the arrtibutes collection of text1, so that will get me th
string arguments and/or literals, but is there any way to deal with variables like the name of an array ?

LE
   
    ----- bruce barker wrote: ----
   
    you can dynamically detect if a control has a handler, but you won't kno
    what parametrs it expect
   
    <input id=text1 type=text onchange="doChange(this,'myData')"><input id=text2  type=text ><script
        if (document.getElementById('text1').onchange != null
           document.getElementById('text1').onchange()
    </script
   
   
    -- bruce (sqlwork.com
   
    "lester" <anonymous@discussions.microsoft.com> wrote in messag
    news:E11B2464-84EC-4F1C-882D-E8DC1AD413D5@microsoft.com..
    >> I want to dynamically check on the client side to see if a control has a
    onchange event handle
    > and then if so, to call it.  Does this sort of functionality exist withi
    javascript ??  It's sort o
    > similar to the SQL's EXECUTE( 'somestring' ) functionality
    >> Thanks
    >> LE
lester - 01 Mar 2004 23:01 GMT
Actually, since this is all interpreted, something is taking the string "doChange(this,'myData')" and
parsing and executing it.  Can I get access to that functionality ?

LES    
    ----- bruce barker wrote: ----
   
    you can dynamically detect if a control has a handler, but you won't kno
    what parametrs it expect
   
    <input id=text1 type=text onchange="doChange(this,'myData')"><input id=text2  type=text ><script
        if (document.getElementById('text1').onchange != null
           document.getElementById('text1').onchange()
    </script
   
   
    -- bruce (sqlwork.com
   
    "lester" <anonymous@discussions.microsoft.com> wrote in messag
    news:E11B2464-84EC-4F1C-882D-E8DC1AD413D5@microsoft.com..
    >> I want to dynamically check on the client side to see if a control has a
    onchange event handle
    > and then if so, to call it.  Does this sort of functionality exist withi
    javascript ??  It's sort o
    > similar to the SQL's EXECUTE( 'somestring' ) functionality
    >> Thanks
    >> LE
bruce barker - 02 Mar 2004 01:32 GMT
the browser builds an anonymous function for the onchange string

<input id=text1 type=text onchange="doChange(this,'myData')">

is equivalent of:

   object.onchange = new Function("doChange(this,'myData')");

to dynamically execute javascript, just use the eval.

   a = eval('1 + 2');

or

   <input id=text1 type=text onchange="doChange(this,'myData')">
   <script>
       eval(document.getElementById('text1').attributes['onchange'].value);
//
   </script>

but the problem will be that the parameter "this", will not be the control,
but rather the window object (owner of anonymous scripts).

-- bruce (sqlwork.com)

> Actually, since this is all interpreted, something is taking the string "doChange(this,'myData')" and
> parsing and executing it.  Can I get access to that functionality ??
[quoted text clipped - 21 lines]
>      >> Thanks,
>      >> LES

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.