Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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.

Phil


In reply to Re: Adding fields to a form using Catalyst/TT by philcrow
in thread Adding fields to a form using Catalyst/TT by HuckinFappy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2024-03-28 22:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found