[Javascript] Doubly-indirected function declaration

Roland Neilands rneilands at pulsemining.com.au
Wed Aug 6 19:29:59 CDT 2003


David,

Best example I could find to do this:
http://www.faqchest.com/msdn/IE-HTML/script-99/script-9908/script99081806_02
551.html

Needs some tweaking, but sounds like your problem.

Cheers,
Roland

> -----Original Message-----
> From: javascript-bounces at LaTech.edu
> [mailto:javascript-bounces at LaTech.edu]On Behalf Of David Lovering
> Sent: Thursday, 7 August 2003 9:47 AM
> To: [JavaScript List]
> Subject: [Javascript] Doubly-indirected function declaration
>
>
>
> I've got something of a teaser -- I'm building a hot-link list which
> connects to a single function with parameters which are determined at
> build-time (and will vary wildly from job-to-job, day-to-day, etc.).  To
> visually organize these babies I'm inserting the hotlinks inside a table.
> Rather than try to use static HTML to "guess" magically what values should
> be shipped to each function invocation cited by the hotlink, I'm
> attempting instead to use the createElement process to insert a
> reference to
> an on-click handler at each point, for example
>
>         for (var i=0; i<maxVal; i++) {
>             blah-blah-blah
>
>             var paramlist = "query_parent.php?name=" + formName + ..... +
> "&type=table";
>
>             blah-blah-blah
>
>             function launchquery(paramlist) {
>                 var win =
> window.open(paramlist,"","titlebar=no,menubar=yes,location=no,stat
> us=no,link
> s=no");
>             }
>
>             blah-blah-blah
>
>             newRow = myDoc.createElement("TR");
>             newRow.style.cursor = "hand";
>             myTd = myDoc.createElement("TD");
>             myTd.innerHTML = "yada-yada";
>             myTd.onclick = function anonymous(){launchquery(paramlist)}
>             newRow.appendChild(myTd);
>             topRow.appendChild(newRow);
>         }
>
> I don't need to go into the details of how topRow is defined -- suffice to
> say, it is the row below which the insertion is to take place.
>
> The PROBLEM (!!!) is that the interior of the call-handler isn't defined
> until the event which invokes it, by which time the loop has run
> its course
> and the value(s) which get handled by launchquery are the last one(s)
> defined -- NOT the ones which are defined at build time.  This sucks.
>
> I need a comparable method which will take the values defined at
> load-time,
> and stuff them into the invocation, and then leave them unaltered.
>
> Any ideas?  I've tried all sorts of variations on eval, exec, etc., and so
> far there is no joy in Mudville.
>
> -- Dave Lovering
>
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>



More information about the Javascript mailing list