How to get the record id in the dynamic page?

In other word, how can I get the value of the linking field in the collection table. e.g. simple example

Result: console.log($w(‘#bedrooms’).text); ===> Bedrooms ( field defult value?)
Expect: console.log($w(‘#bedrooms’).text); ===> 2 ( value of the collection table )
On the Web screen, the value of 2 is being displayed.

Thanks,