This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - Identify control without knowing the id or name

[email protected] - Wednesday, July 6, 2011 9:43 AM:

Hi, all:

  I'm new to Javascript and also to ARAS development.  I'm working with textboxes on a form and have written a method that will fire onBlur and manipulate the value of a text box, but without knowing its name or id ahead of time.  Normally I would pass the word "this" to the function to identify the control that called it, like so:

<INPUT TYPE="text" ID="myText" NAME="myText" onBlur="formatText(this)">

...but I've been unable to figure out how to do that in ARAS. The method will always have to identify the control
 that called it. Right now I call the method by adding a relationship to it in the field event of the text box
 I'm trying to work with, and I don't see any way to insert the keyword  "this". I've tried converting the text box to
an HTML object and adding "onBlur(this)" but I get an error saying an  object was expected. How can I find the
 identity or tag name of the field that called the method?

Thanks,

Jeremy


Brian - Thursday, July 7, 2011 11:31 PM:

Hi Jeremy,

Field events like onBlur receive a "this" context item from Innovator. The "this" context item for a field event is the Field Object that the event was called from.

So to manipulate the text you should just be able to use:

this.value = "My New Value";

Have you had a look at the Programmers Guide available on the Downloads : Documentation page?

http://www.aras.com/support/documentation/

Cheers,

Brian.



[email protected] - Friday, July 8, 2011 8:57 AM:

Hi, Brian:

     Thanks for getting back to me!  I've tried several variations of that code and nothing works.  I've tried several combinations including the following: 

function myFunction()

{

this.value = "success";

}

and

function myFunction(t)

{

var field = t;

field.value = "success";

}

I'm sure I've got the method hooked  up to the field correctly (I select the text field, add a relationship, select the method, select "onBlur" as the event) and I've got other methods that run fine.  In the others I call out the control by tag name and I can find them and manipulate their values with no problems.  In this case I will never know the name.  Any suggestions?

Thanks again,

Jeremy 



Brian - Friday, July 8, 2011 9:04 AM:

Have you just tried

this.value = "success";

No function declaration?

put       alert("Method called");

just before the line so that you get feedback that the method is actually being called.

I tested this on a field. Added an onBlur event with only             this.value = "something";   and it works for me.

Brian.



[email protected] - Friday, July 8, 2011 9:34 AM:

Brian:

     Thanks very much!!  That was exactly the problem.  Many points to you, sir.

-Jeremy