...

View Full Version : Call Object Method



moonpeep
12-08-2012, 12:10 AM
I feel like this is an incredibly novice question, but I have to start somewhere.

I have a signature applet on an html form that works just fine.


<head>
<script type="text/javascript" src="ink_signatures.js"></script>
</head>
<script type="text/javascript">
new sform.Signature({
id: 'fcmsig',
field_name: 'fcmsig',
form_name: 'myform',
file_name: 'fcmsig.png',
caption: 'Signature',
w: 450,
h: 125,
css: 'signature_area'
});
</script>


What I'm having trouble with is using the "Object Method" to clear the canvas. The only information I have is to use: signature_object.reset();

So my Clear Signature button looks like this:


<input type="button" data-theme="b" value="Clear" onclick="signature_object.reset(fcmsig);"/>


I'm clueless how to correctly trigger the reset. Any help would be greatly appreciated.

Old Pedant
12-08-2012, 01:16 AM
Since you create the Signature object using (in part):


id: 'fcmsig',

it is *POSSIBLE* that you would then use

onclick="signature_object.reset('fcmsig');"/>
(with quotes around the id, notice!).

But I think it is more likely that you should have done

var mySigObject = new sform.Signature({
id: 'fcmsig',
field_name: 'fcmsig',
form_name: 'myform',
file_name: 'fcmsig.png',
caption: 'Signature',
w: 450,
h: 125,
css: 'signature_area'
});

and then you would use


onclick="mySigObject.reset();"

That is, you call methods on the object you SPECIFICALLY created.

*********
Without seeing the docs for "signature.js", though, it's going to be just a quess. Everybody designs APIs differently, unfortunately, so if you don't read the docs, you can't know for sure.

Old Pedant
12-08-2012, 01:23 AM
HINT: If neither of the above work and you can't figure it out from the documentation, it might help if you gave us a URL link to the documentation.

moonpeep
12-08-2012, 04:03 PM
Perfect!

I used:


var myfcmsig = new sform.Signature({

and then:


onclick="myfcmsig.reset();"/>


Exactly what I needed. Thanks so much!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum