setting formfield value onLeave()

Questions, tips and tricks and techniques for scripting in Servoy

setting formfield value onLeave()

Postby arumalla » Tue Sep 23, 2003 7:03 pm

Whats wrong in this code?


var catvalue=controller.getDataProviderValue(catno)
if (catvalue= "FRP019")
{
controller.setDataProviderValue(prodname, "Fmoc-L-Isoleucine PEG Resin")
}

am I missing something?

what am trying to do is if the catalog number is "XXXXX" then the Product value should automatically sets when I change the cursor from the catno field.

any help is appreciated
Thanks & Regards

Chandra Arumalla

chandraa@synpep.com
www.synpep.com
User avatar
arumalla
 
Posts: 41
Joined: Thu Apr 24, 2003 12:02 am
Location: Dublin, CA

Postby automazione » Tue Sep 23, 2003 11:56 pm

if (catvalue == "FRP019")

should work.... In javascript equal is ==

bye
Enrico Arata
Servoy Italia
automazione
 
Posts: 366
Joined: Thu Apr 24, 2003 11:37 am
Location: Torino, Italy

Postby arumalla » Tue Sep 23, 2003 11:59 pm

automazione wrote:if (catvalue == "FRP019")



is not working I tried it.
Thanks
User avatar
arumalla
 
Posts: 41
Joined: Thu Apr 24, 2003 12:02 am
Location: Dublin, CA

Setting form field value

Postby svenjauhe » Wed Sep 24, 2003 8:55 am

Hello arumalla,

I wonder if enabling the field for input helps?

var catvalue=controller.getDataProviderValue(catno)
if (catvalue== "FRP019")
{

elements.prodname.enabled = true;

controller.setDataProviderValue(prodname, "Fmoc-L-Isoleucine PEG Resin")
}




Sven
User avatar
svenjauhe
 
Posts: 14
Joined: Mon Jun 16, 2003 4:22 am
Location: Finland

Postby Jan Blok » Wed Sep 24, 2003 3:15 pm

Note: getDataProviderValue(dataprovidername) returns the value dynamicly based on the name you provide (I can't imagine a sitution you whould ever need this, but was requested in the past by user)
Normally you just use the dataprovider name directly example:
------------------------
var calc = order_id + customer_id;
------------------------
Here order_id and customer_id contain the data from current record column/calc/etc.

You are using getDataProviderValue in a very strange way... this is the same:
------------------------
var calc = order_id + customer_id;
var calc = getDataProviderValue('order_id') + customer_id;
------------------------

so normally no need to use getDataProviderValue !
Jan Blok
Servoy
Jan Blok
 
Posts: 2684
Joined: Mon Jun 23, 2003 11:15 am
Location: Amsterdam

Postby maarten » Wed Sep 24, 2003 8:50 pm

var catvalue=controller.getDataProviderValue(catno)
if (catvalue= "FRP019")
{
controller.setDataProviderValue(prodname, "Fmoc-L-Isoleucine PEG Resin")
}


This indeed works if you put catno and prodname between quotes!
controller.getDataProviderValue('catno')
controller.setDataProviderValue('prodname', "Fmoc-L-Isoleucine PEG Resin")

But as Jan Blok also pointed out, the next code is more obvious:
if (catno == "FRP019")
{
prodname = "Fmoc-L-Isoleucine PEG Resin";
}

suggestion:(noscripting needed)
1)create a table PRODUCTS with columns catno and prodname
2)create a relation tableX:catno = tablePRODUCTS:catno.
(where tableX is the table where the above script/form was placed in)
3)make column prodname in tableX a lookup, based on this relation.

Hope this helps.
Maarten Berkenbosch
User avatar
maarten
 
Posts: 797
Joined: Wed Apr 23, 2003 10:52 pm
Location: Amersfoort, Netherlands

Postby Guest » Thu Sep 25, 2003 2:10 am

Thanks Maarten,
It just worked as I wish... Thanks

May be I am thinking too much after being a programmer all these years. but with Servoy we don't need to think that much. I think I took a little more time to realize this.

Thanks for the Great Product ever known to mankind.

~Chandra
Guest
 


Return to Methods

Who is online

Users browsing this forum: No registered users and 3 guests