# App Lab - dropdown

**URL:** <https://forum.code.org/t/app-lab-dropdown/25862>\
**Category:** Website and Tools Questions\
**Created:** [March 25, 2019, 12:21pm UTC](https://forum.code.org/t/app-lab-dropdown/25862 "2019-03-25T12:21:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pwright](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/pwright/32/4384_2.png) [@pwright](https://forum.code.org/u/pwright)\
**Post date:** [March 25, 2019, 12:21pm UTC](https://forum.code.org/t/app-lab-dropdown/25862/1 "2019-03-25T12:21:12Z")

</div>

Morning All!! I am still new to coding and learning very fast (will be teaching computer science this fall). I am creating an app for a class I am taking and I need help because I am lost!!

I have it set up that are searching colleges that are either under or over $25,000 a year in tuition and I have a data set where I have 3 columns (college, price, students). I am using a drop down to select the college and I want the other 2 columns to auto populate in the text box areas but I have no clue what the coding is. I have spend hours looking online to figure out how and I am just missing something!! Any help would be appreciated!!

Here is what I have:  
readRecords(“under25k”, {}, function(records) {  
var college\_list = ;  
for (var i=0; i \< records.length; i++) {  
appendItem(college\_list, records[i].college);  
}  
setProperty(“dropdownU”, “options”, college\_list)  
});

readRecords(“over25k”, {}, function(records) {  
var college\_list = ;  
for (var i=0; i \< records.length; i++) {  
appendItem(college\_list, records[i].college);  
}  
setProperty(“dropdownO”, “options”, college\_list)  
});

I have this as well but I know it is not correct because I have changed it a 1,000 times!! lol

onEvent(“dropdownU”,“change”, function(event){  
readRecords(“under25K”, {name:getProperty(“dropdownU”,“text”)}, function(event){  
var price\_list = ;  
for (var i=0; i \< records.length; i++) {  
appendItem(price\_list, records[i].price);  
}  
setProperty(“price1”,“text”, price\_list)  
});

HELP!!

here is my app:

> **[Check out what I made](https://studio.code.org/projects/applab/_pVY5hnqWGQJfAPSNBhInf2OyzTGBYDdbf-27zGtsEI)**
>
> I wrote the code myself with Code.org

---

<div class="post-metadata">

**Author:** ![teacher](https://avatars.discourse-cdn.com/v4/letter/t/c6cbf5/32.png) [@teacher](https://forum.code.org/u/teacher)\
**Post date:** [March 28, 2019, 4:24pm UTC](https://forum.code.org/t/app-lab-dropdown/25862/2 "2019-03-28T16:24:03Z")

</div>

I have an immediate interest in what you are trying to do. I will play with a copy of your code and get back to you here when I know more … Can you paste an example .csv of your data table(s) – the data tables do not come with a remix. … Okay, give this a try: [https://studio.code.org/projects/applab/Av27xl6SQbGRp4Foamv6ZUiorUxz8OK9scGJYCh7\_kg](https://studio.code.org/projects/applab/Av27xl6SQbGRp4Foamv6ZUiorUxz8OK9scGJYCh7_kg)

This should be the only place I made changes:

onEvent(“dropdownU”,“change”, function(event){  
var selectedText = getProperty(“dropdownU”,“text”);  
[//console.log](https://console.log)("onEvent dropdownU, selected text is "+selectedText);  
readRecords(“under25k”, {college:selectedText}, function(record){

if (record.length \> 0) { // length should be one (of type object)  
[//console.log](https://console.log)("onEvent dropdownU, returned record length is "+record.length);  
[//console.log](https://console.log)("onEvent dropdownU, record.price = "+record[0].price);  
[//console.log](https://console.log)("onEvent dropdownU, record.college = "+record[0].college);  
[//console.log](https://console.log)("onEvent dropdownU, record.students = "+record[0].students);  
[//console.log](https://console.log)("onEvent dropdownU, record = "+record[0]);  
// retrieve price entry for this record  
var textPrice = “$”+record[0].price;  
// set the text field on the applicable UI element  
setText(“price1”,textPrice);

```
var textStudents = record[0].students;
setText("numbers1",textStudents)

```

}  
else {  
console.log("onEvent dropdownU, returned records length is "+record.length);  
}  
}); // end of function(record)  
}); // end of function(event)

---

<div class="post-metadata">

**Author:** ![pwright](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/pwright/32/4384_2.png) [@pwright](https://forum.code.org/u/pwright)\
**Post date:** [March 28, 2019, 4:47pm UTC](https://forum.code.org/t/app-lab-dropdown/25862/3 "2019-03-28T16:47:13Z")

</div>

Yes and here are some of the data:

under 25,000

| id | college | price | students |
| --- | --- | --- | --- |
| | Select A College | | |
| 1 | Ashland University | 20,392 | 3,716 |
| 2 | Binghamton University–SUNY | 22,164 | 13,491 |
| 3 | Bowling Green State University | 18,332 | 14,334 |
| 4 | Brigham Young University–Provo | 5,300 | 30,221 |
| 5 | California State University–Fresno | 17,209 | 21,482 |

over 25,000

| id | college | price | students |
| --- | --- | --- | --- |
| | Select A College | | |
| 1 | Adelphi University | $34,034 | 4,852 |
| 2 | American University | $44,853 | 7,909 |
| 3 | Andrews University | $27,684 | 1,733 |
| 4 | Arizona State University–Tempe | $25,458 | 41,828 |
| 5 | Auburn University | $28,840 | 21,786 |

Thanks!!
