This topic is locked

depended dropdown

10/20/2009 10:32:33 PM
PHPRunner General questions
M
meirco author

1.You have this in the manual

----

You can also use chain of dependent dropdown boxes. For example, Supplier field content can depends on Products field, which in its turn depend on Products category field.
Also you can have more than one dependent dropdown box tied to the same master dropdown control.

---

can you show an example.
2. When you use the lookup/with dropdown can you use the concatenated display fields to populate fields in add page

if so how.

-----

3.Help needed

tascodes table contains category,activity,code2,description,tcode

if category is selected from dropdown and activity is depended select on category, the return value from this select is a unique code2.

---

in VE i have this script

<script>
document.forms.editform.value_activity.onchange = function()

{

if(document.forms.editform.value_activity.value.length>==3)

alert("Enter the 3 Letters -->>[" +document.forms.editform.value_activity.value+"]<<--in the TASK Field ");
}

</SCRIPT>

document.forms.editform.value_activity.value does display my 3 letter code. which is code2
in BEFORE RECORD ADD I have this
global $dal;

$rstmp = $dal->taskcodes->Query("code2='".$values["code2"]."'","");

$data = db_fetch_array($rstmp);

$values["description"] = $data["description"];

$values["tcode"] = $data["tcode"];
I want the query to fetch the record in taskcodes based on code2

I want to parse the $data for values of fields so I can populate my fields in my current add form.

I was expecting that after I select activity my description and tcode field would populate.
How do you accomplish that.

is there an easier way to access a foreign table for values to populate add/edit forms with or without a lookup.
---
Thank-You.

J
Jane 10/21/2009

Please see my answers below:

  1. check 'How to setup dependent dropdown boxes on Edit/Add pages' tutorial here:

    http://www.xlinesoft.com/phprunner/php-database.htm
  2. use custom expression in the Display field dropdown on the "Edit as" settings dialog.
  3. to fill description and tcode fields with values on the fly set up these fields as dependent dropdown boxes. Use code2 field as main dropdown.

M
meirco author 10/21/2009



Please see my answers below:

  1. check 'How to setup dependent dropdown boxes on Edit/Add pages' tutorial here:

    http://www.xlinesoft.com/phprunner/php-database.htm
  2. use custom expression in the Display field dropdown on the "Edit as" settings dialog.
  3. to fill description and tcode fields with values on the fly set up these fields as dependent dropdown boxes. Use code2 field as main dropdown.



Jane
1.1. This tutorial does not show how to do
You can also use CHAIN of dependent dropdown boxes. For example, Supplier field content can depends on Products field, which in its turn depend on Products category field.
Also you can have MORE THAN ONE dependent dropdown box tied to the same master dropdown control.
I mastered The simple dependency. need help with CHAIN and MORE THAN ONE. EXAMPLE PLEeeASE.

2. That is my question When I use custom expression in the display field how do you populate the fields in the current add page with the custom expression parts.
The tcode and description CAN NOT BE DROPDOWNS. any other way .
I need to be able to populate many fields in add/edit form with returned lookup/dropdown values .

you currently return only one value the link field.
3. is there any other way to access a foreign table for values to populate add/edit forms.
for instance

dropdown select lastname
dropdown select firstname
if i have a table customer with lastname,firstname,city,state,zip,email,telephone as the lookup table
need to populate
address

city

state

zip

etc.
in add/edit form.

I know I can do this with ajax/dropdown but for now I am required to only use dropdown.

J
Jane 10/22/2009
  1. Here is a sample:

    2 tables: orders and customers.

    Orders table: OrderID, CustomerID, CustomerName, CustomerAddress, OrderDate, etc.

    CustomerID is the main drodpown, CustomerName and CustomerAddress are dependent dropdowns.
    2, 3. Unfortunately PHPRunner do not support to fill another text fields on the page with values from dropdown (link or display values).

    You need to select these fields as dependent dropdown boxes or fill it manually with custom JavaScript code. Unfortunately we don't have a ready to go solution for this.

M
meirco author 10/22/2009


  1. Here is a sample:

    2 tables: orders and customers.

    Orders table: OrderID, CustomerID, CustomerName, CustomerAddress, OrderDate, etc.

    CustomerID is the main drodpown, CustomerName and CustomerAddress are dependent dropdowns.
    2, 3. Unfortunately PHPRunner do not support to fill another text fields on the page with values from dropdown (link or display values).

    You need to select these fields as dependent dropdown boxes or fill it manually with custom JavaScript code. Unfortunately we don't have a ready to go solution for this.


Thank-You for responding.

OK so custom Javascript here is what I have
ADDing Time table record.
I have

  1. category field is lookup/dropdown looking in table tcategory

    link field category

    display field concat(keycode,'--',category)
  2. activity field is a lookup/dropdown in table taskcodes

    link field is description

    display field is activity

    dropdown is dependent on category control category

    category field CATEGORY
    this returns DESCRIPTION in the Linkfield (GREAT)

    the record returned is a unique single record in taskcodes
    IN VE

    <script>
    document.forms.editform.value_activity.onchange = function()

    {

    if(document.forms.editform.value_activity.value.length>=1)

    document.forms.editform.value_description.value = document.forms.editform.value_activity.value;

    }

    </SCRIPT>

    (Great) I populated my description field.

    How can I now select the other matching fields from taskcodes such as

    document.forms.editform.valuetcode.value = document.forms.editform.value??????.value;

    document.forms.editform.valuecode2.value = document.forms.editform.value??????.value;
    without doing another select, since the record in taskcodes contains all the information I need.
    is there anthing like
    document.forms.editform.value_code2.value = taskcodes.code2; or

    document.forms.editform.value_code2.value = taskcodes->code2;
    if not.
    since i have a unique description can I use it as a variable in a DAL QUERY.
    in BEFORE RECORD ADD I have this
    global $dal;

    $rstmp = $dal->taskcodes->Query("description='".$values["description"]."'","");

    $data = db_fetch_array($rstmp);

    $values["description"] = $data["description"];

    $values["tcode"] = $data["tcode"];

    $values["code2"] = $data["code2"];

    or before SAVE can I grab the values as

    global $dal;

    $rstmp = $dal->taskcodes->Query("description='".$values["description"]."'","");

    $data = db_fetch_array($rstmp);

    $values["description"] = $data["description"];

    $values["tcode"] = $data["tcode"];

    $values["code2"] = $data["code2"];

    or any other way.
    Your help is much appreciated.
    Meir

J
Jane 10/23/2009

Hi,
this code won't work. Before record added event is executed after submitting form.

You should pre-select all values before and then select values from JavaScript array on the page. This task requires a lot of custom coding and you should be familiar with JavaScript for that. Unfortunately we don't have a ready to go solution for this.

M
meirco author 10/26/2009



Hi,
this code won't work. Before record added event is executed after submitting form.

You should pre-select all values before and then select values from JavaScript array on the page. This task requires a lot of custom coding and you should be familiar with JavaScript for that. Unfortunately we don't have a ready to go solution for this.


you should be familiar with JavaScript for that. ???

what do mean. ???

just because I started 2 months ago I can't write a Javascript to retrieve a record from a table.

all I get is "Unfortunately we don't have a ready to go solution for this."

Are you trying to tell me something. ???
PHPRunner. Build great looking PHP+MySQL web sites with no programming. what happened to that.

all I'm asking is to be able to do what I always done with lookup tables . retrieve data from a foreign table to pre-fill text fields

on my data entry form.

so far I got 3 we cant do this. How do I apply for a refund.
Java script to retrieve data from mysql
var xmlhttp;
function showcodes(str)

{

xmlhttp=GetXmlHttpObject();

if (xmlhttp==null)

{

alert ("Browser does not support HTTP Request");

return;

}

var url="getcodes.php";

url=url+"?q="+str;

url=url+"&sid="+Math.random();

xmlhttp.onreadystatechange=stateChanged;

xmlhttp.open("GET",url,true);

xmlhttp.send(null);

}
function stateChanged()

{

if (xmlhttp.readyState==4)

{

document.getElementById("txtHint").innerHTML=xmlhttp.responseText;

}

}
function GetXmlHttpObject()

{

if (window.XMLHttpRequest)

{

// code for IE7+, Firefox, Chrome, Opera, Safari

return new XMLHttpRequest();

}

if (window.ActiveXObject)

{

// code for IE6, IE5

return new ActiveXObject("Microsoft.XMLHTTP");

}

return null;

}
thanks for the insult.

J
Jane 10/28/2009

I recommend you to contact support@xlinesoft.com directly with complex coding questions.