Page 1 of 1

How to use button object to run javascript code?

Posted: Thu Jul 28, 2011 4:56 am
by FBC-Tim
Problem:
I wanted to put a button on the body of the edit form that would run a JavaScript function I had defined in the "Javascript" tab for that form.
The button object has a place to put a form to launch, a Record ID, etc. but does not have a place for a straight JavaScript function call.
I wonder if it would be useful to add the ability for a button object to call a JavaScript function?

My Solution:
For now I have got around this by using a HTML Object and placing button code in it (see below). This is working well on screen but has the side effect of creating a 'hidden' phantom object that may make future maintenance harder for someone else.

Code: Select all

<input type="button" value="My Stuff" style="width:64px;" name="buttonMyStuff" id="buttonMyStuff" onclick="doMyStuff()" class="button">
I know I can use an 'Extra Action Button' to run JavaScript easily, but I wanted the button located down in the body of my edit form.
Is there a better way to solve this problem?

Re: How to use button object to run javascript code?

Posted: Thu Jul 28, 2011 8:59 am
by admin
FBC-Tim,

Not very intuitive but, this is how you do it (you cant actually double click a button).

The explanation can be found here in the wiki http://wiki.nubuilder.com/tiki-index.ph ... uilderDocs

But try this..

Capture3.PNG
Hope that helps.

Steven

Re: How to use button object to run javascript code?

Posted: Fri Jul 29, 2011 1:38 am
by FBC-Tim
I missed that in the wiki, thanks for pointing it out.
Works well ;)

Re: How to use button object to run javascript code?

Posted: Mon Aug 01, 2011 5:29 am
by admin
Cool!