Collection Data Search in column1 and storing column2 data in a variable.

I am creating a page on my site in which there will be a input box (#input1) and one search button (#button1) and one table (#table1) and one text box (#text173) and i have a database (STUDENT_NAMES). Database “STUDENT_NAMES” has two fields (Rollnumber , Name) .

Now what i want to do is that when someone come on my search page to find name of a student and input rollnumber in the #input1 and then press search button. then my javascript should first search for Rollnumber in the “STUDENT_NAMES” database and after finding Rollnumber it should store the value of the “Name” field of the column2 ( which is next to the found Rollnumber row) in a variable .

and after storing “Name” in a variable the name should display in the text box " #text173" .

please note : #table1 i used to first display the both fields Rollnumber and name after search but i am not able to store the value “name” in a variable after searching Rollnumber.
please help.

You are searching for COLUMN-1-DATA, but you want to store COLUMN-2-DATA, found on COLUMN-1 ???

This for you can use the wix-data-api.

Something like this…

import wixData from 'wix-data';

let DBFIELDS=[], OUTPUT_FIELDS=[]; 

//-------- USER-INTERFACE -------------------------
let DATABASE = "STUDENT_NAMES"; 
//---[ DB-INPUT-Field-Settings]--------------
DBFIELDS[0] = "rollnumber"; //<--- DEFINE-INPUT-FIELD-here  
//---[ DB-OUTPUT-Field-Settings]--------------
OUTPUT_FIELDS[0] = "name" //<DEFINE-OUTPUT-FIELD-here 
//-------- USER-INTERFACE -------------------------

$w.onReady(async()=>{
    let VALUE = "YOUR_SERACH_VALUE_HERE";

    wixData.query(DATABASE) 
    .eq(DBFIELDS[0], VALUE)
    .find()
    .then((res) => {
        let items = res.items
        console.log("ITEMS: ",  items);
        let output = items.map(item=>item[OUTPUT_FIELDS[0]])
        console.log(output);
    });
});

You will have to modify this code for your own needs, expanding its function !!!

yes i just want to find rollnumber but i want to store name of that student in a variable and display on a textbox. in simple words Find roll number but display and store name propotional to that rollnumber.

You have already an example-code, try to get it to work for your needs and take a look onto the CONSOLE .