Convert Lotuscript to Javascript

Hi,

I have a lotuscript to append text whenever the user press the button. I have to deploy that code via web and I have read that I will have to convert that to javascript. I have not tried using javascript. PLease help me convert this to javascript.

Sub Click(Source As Button)

Dim workspace As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Set uidoc = workspace.CurrentDocument

Call uidoc.FieldAppendText _

( “body”, “Over here, balloon man!” )

End Sub

Any help will be appreciated.

Thank you.

Subject: Not just to “convert”…

You need to rewrite it using Javascript.

To make it easy, I would actually use jQuery, if you link to jQuery on a CDN it is very easy to add the code on a web page.

Your code would looks something like this (untested and with some assumptions (for example that you have set an id on your field):

$(“#yourButton”).on(“click”, function(){

var newValue = $(“#fieldBody”).val();

newValue = newValue + “Add this text.”;

$(“#fieldID”).val(newValue);

});

I have been writing a couple of blog entries about jQuery, specifically witha Domino focus. You can find the articles here: Search Results for “jquery” – TexasSwede

Subject: Download jQuery for a single button, really?

Attaching an event listener is a piece of cake in any case, but you can always just put the appropriate code directly into the button’s onclick when it’s this simple:

this.form.elements[‘body’].value += ‘Over here, balloon man!’; return false;

There is no excuse, ever, for forcing the download of tens of kilobytes of library code AND vastly increase the amount of code you’ve had to write to boot simply because you can’t be bothered to learn vanilla JS. If it were difficult or complicated and not likely to work across browsers reliably, then go for it, but that’s never a problem with user fields and buttons; they’ve been stable and natively cross-browser since the Gen4 browser days.

If you prefer an event handler, you’ll need to use preventDefault() (and, perhaps, stopPropagation()) instead of return false;.