If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Does someone have a better way....There has to be a better way.

08-09-2013, 06:14 PM

In a Form application, the user fills out profile information to setup an account. At the bottom of the form they select the product they want to purchase from a pull down (SELECT). The SELECT is filled from a product database that is different from the profile database that the application uses. All of this is easy to work within the Scriptcase application builder. As part of the interface to the user, I wanted to indicate the product number and price of the product the user selects in the pull down by showing this information next to the pull down SELECT. The product number and price are in the product table (not the profile database used by the application).

I could not find a way to make the information from the product database available to ajax or javascript so that the information could be dynamically changed. I ended up creating a SQL query to the database in the OnLoad Event and defining javascript variables with echo() as shown:
// get product records
$product_sql =
"SELECT
ProdType,
ProductNumber,
ProductPrice,
Pass_Tbl_Code
FROM
Products
WHERE
(ProdType = 'MM')";
sc_lookup (mmp, $product_sql, "conn_access_WebDB");

I then created a field which was paced in the block with and beside the SELECT. The field label and text are initially blank. I then had to run the application and view the source to find out what HTML ID Scriptcase was giving to the SELECT and to the label field I created.

With this information I created a Javascript Edit for OnChange to the SELECT in which I changed the value of the label field that I had created based on the change in value of the SELECT. See below:

This works, but I believe that there has to be a better way to do this more within the standard framework of Scriptcase. I think that I should NOT have to look into the generated source to accomplish this.

This works, but I believe that there has to be a better way to do this more within the standard framework of Scriptcase.

Yes ...

Form Settings / Ajax Events => Create an onChange Event on your Select/Pulldown-Field. In the Code-Editor you write normal php code. Click on "?" at the right upper (editor) side for more documentation ...