in reply to parsing javascript with perl

I'm not sure what your example code has to do with javascript, but if I understand your question, you would like to fill in an HTML form from the web server to allow a user to edit a database record?

If that's the case, then what you want is the HTML::FillInForm module, it takes HTML text and a hash of values and matches the hash keys with form field names. It knows all about input fields, popups, checkboxes and will encode text correctly for display (in case your text contains things like '&', '<' and '>').