Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: Adding fields to a form using Catalyst/TT

by philcrow (Priest)
on Oct 13, 2006 at 18:40 UTC ( #578202=note: print w/replies, xml ) Need Help??

in reply to Adding fields to a form using Catalyst/TT

Javascript is a very nice language which does not deserve its even worse reputation than our favorite language. I was in your position about 6 months ago, so I read a book on the language (Java Script the Complete Reference 2ed., I heard a new O'Reilly title was coming soon, but it wasn't soon enough) and discovered that javascript is very flexible in surprisingly perlish ways (although the syntax looks different than ours at first glance).

A previous poster mentioned libraries, which are great. But, understanding comes to me from rolling a few things myself first. Otherwise, I can't conceive of what the library is up to.

Here is a little sample pulled from recent code (Bigtop's tentmaker editor to be specific). I've pruned it a little bit to make it clearer and more general.

function add_to_div( div_to_change, new_div_text ) { var div_area = document.getElementById( div_to_change ); var new_node = document.createElement( 'div' ); new_node.innerHTML = new_div_text; div_area.appendChild( new_node ); }
Now this is not fancy. Library code would be nicer in a number of ways (notably in cross browser support). But this shows how easy it is to augment an existing document object model (DOM).

Other than javascript, you can only make round trips to the server, which is <pun_warning /> anything but refreshing.


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://578202]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2023-01-28 06:28 GMT
Find Nodes?
    Voting Booth?

    No recent polls found