This topic is locked

Readonly field simple question

12/5/2008 12:29:50 AM
PHPRunner General questions
S
sumit270 author


I need to add this fuction in the Add page, as shown in the screenshot.

And the field should be ReadOnly Field

Is this possible?

S
sumit270 author 12/5/2008

By plus sign i don't mean adding, but to catenate.

and the category id and size id are drop down menu

J
Jane 12/5/2008

Hi,
there is no easy way to change readonly value dynamically.

This task requires a lot of custom JavaScript code. Unfortunately we don't have a ready to go solution for this.
As workaround construct Product Name value in the Before record added event on theEvents tab.

Here is a sample:

$values["product_name"] = $values["categoryID"].$values["sizeID"];

S
sumit270 author 12/5/2008
$values["product_name"] = $values["categoryID"].$values["sizeID"];


This worked, but it returned with the ID values. is there any way to change this ID values to the name of the category and the size name which is related to the ID?

J
Jane 12/5/2008

Hi,
select category name and size name from corresponding tables manually and fill product_name field.

Here is a sample code:

global $dal;

$rs1 = $dal->Categories->Query("CategoryID=".$values["categoryID"],"");

$data1 = db_fetch_array($rs1);
$rs2 = $dal->Sizes->Query("SizeID=".$values["sizeID"],"");

$data2 = db_fetch_array($rs2);
$values["product_name"] = $data1["category_name"].$data2["size_name"];

S
sumit270 author 12/5/2008

that didn't work
in order to make it work i will have to know what the code means
can you please explain what these means

  1. global $dal;
  2. $rs1 = $dal->Categories->Query("CategoryID=".$values["categoryID"],"");
  3. $data1 = db_fetch_array($rs1);

J
Jane 12/5/2008

Hi,
following code select category name from table categories using entered categoryID($values["categoryID"]):

global $dal;

$rs1 = $dal->categories->Query("categoryID=".$values["categoryID"],"");

$data1 = db_fetch_array($rs1);



Actual category name is in the $data1["CategoryName"].
Please make sure you have replaced all highlighted names with your actual ones.

S
sumit270 author 12/5/2008

WOOT!! it worked.

Thank you so much
and I wish I could do it with Javascript as well

global $dal;

$rs1 = $dal->product_cat->Query("categoryID=".$values["categoryID"],"");

$data1 = db_fetch_array($rs1);
$rs2 = $dal->product_size->Query("sizeID=".$values["sizeID"],"");

$data2 = db_fetch_array($rs2);
$values["product_name"] = $data1["category_name"]." ".$data2["size_name"];
return true;